Search in sources :

Example 16 with IRepositoryNodeConfiguration

use of org.talend.mdm.repository.core.IRepositoryNodeConfiguration in project tmdm-studio-se by Talend.

the class RepositoryViewFilterDialog method solveProcTriCase.

private void solveProcTriCase() {
    IRepositoryViewObject eventMgr = null;
    boolean exist = false;
    for (IRepositoryViewObject conf : enabledConfigs) {
        Item item = conf.getProperty().getItem();
        IRepositoryNodeConfiguration repositoryConf = RepositoryNodeConfigurationManager.getConfiguration(item);
        if (repositoryConf instanceof EventManagerNodeConfiguration) {
            exist = true;
            break;
        }
        if (repositoryConf instanceof IRepositoryViewObject || repositoryConf instanceof TransformerV2NodeConfiguration)
            for (IRepositoryViewObject confi : allConfigs) eventMgr = confi;
    }
    if (eventMgr != null && !exist)
        enabledConfigs.add(eventMgr);
}
Also used : Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) EventManagerNodeConfiguration(org.talend.mdm.repository.core.impl.eventmanager.EventManagerNodeConfiguration) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) TransformerV2NodeConfiguration(org.talend.mdm.repository.core.impl.transformerV2.TransformerV2NodeConfiguration)

Example 17 with IRepositoryNodeConfiguration

use of org.talend.mdm.repository.core.IRepositoryNodeConfiguration in project tmdm-studio-se by Talend.

the class MDMRepositoryActionProvider method init.

@Override
public void init(ICommonActionExtensionSite aSite) {
    CommonViewer commonViewer = (CommonViewer) aSite.getStructuredViewer();
    for (IRepositoryNodeConfiguration conf : RepositoryNodeConfigurationManager.getConfigurations()) {
        IRepositoryNodeActionProvider actionProvider = conf.getActionProvider();
        if (actionProvider != null) {
            actionProvider.setRepositoryViewGlobalActionHandler(this);
            actionProvider.initCommonViewer(commonViewer);
        }
    }
    initCommonViewerForActions(commonViewer);
}
Also used : CommonViewer(org.eclipse.ui.navigator.CommonViewer) IRepositoryNodeActionProvider(org.talend.mdm.repository.core.IRepositoryNodeActionProvider) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration)

Example 18 with IRepositoryNodeConfiguration

use of org.talend.mdm.repository.core.IRepositoryNodeConfiguration in project tmdm-studio-se by Talend.

the class MDMRepositoryActionProvider method fillContextMenu.

@Override
public void fillContextMenu(IMenuManager menu) {
    if (ProxyRepositoryFactory.getInstance().isUserReadOnlyOnCurrentProject()) {
        return;
    }
    IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
    List<AbstractRepositoryAction> finalActions = null;
    for (Iterator il = selection.iterator(); il.hasNext(); ) {
        Object obj = il.next();
        if (obj instanceof IRepositoryViewObject) {
            IRepositoryViewObject viewObj = (IRepositoryViewObject) obj;
            IRepositoryNodeConfiguration conf = RepositoryNodeConfigurationManager.getConfiguration(viewObj);
            IRepositoryNodeActionProvider actionProvider = conf.getActionProvider();
            if (conf != null && actionProvider != null) {
                actionProvider.updateSelection(selection);
                List<AbstractRepositoryAction> actions = actionProvider.getActions(viewObj);
                if (actions != null) {
                    if (finalActions == null) {
                        finalActions = actions;
                    }
                    finalActions = combineActions(finalActions, actions);
                    if (finalActions.size() == 0) {
                        return;
                    }
                }
            }
        }
    }
    // hook action to menu
    for (IAction action : finalActions) {
        if (action instanceof AbstractRepositoryAction) {
            AbstractRepositoryAction groupAction = (AbstractRepositoryAction) action;
            groupAction.selectionChanged(selection);
            if (groupAction.getGroupName() != null) {
                menu.appendToGroup(groupAction.getGroupName(), action);
            } else {
                menu.add(action);
            }
        }
    }
}
Also used : AbstractRepositoryAction(org.talend.mdm.repository.core.AbstractRepositoryAction) IAction(org.eclipse.jface.action.IAction) IRepositoryNodeActionProvider(org.talend.mdm.repository.core.IRepositoryNodeActionProvider) Iterator(java.util.Iterator) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 19 with IRepositoryNodeConfiguration

use of org.talend.mdm.repository.core.IRepositoryNodeConfiguration in project tmdm-studio-se by Talend.

the class MDMRepositoryLabelProvider method getLabelProvider.

protected IRepositoryNodeLabelProvider getLabelProvider(Object element) {
    if (element instanceof IRepositoryViewObject) {
        IRepositoryViewObject viewObject = (IRepositoryViewObject) element;
        viewObject = RepositoryResourceUtil.assertViewObject(viewObject);
        Property property = viewObject.getProperty();
        if (property != null) {
            Item item = property.getItem();
            IRepositoryNodeConfiguration conf = RepositoryNodeConfigurationManager.getConfiguration(item);
            if (conf != null) {
                return conf.getLabelProvider();
            }
        }
    }
    return null;
}
Also used : Item(org.talend.core.model.properties.Item) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) Property(org.talend.core.model.properties.Property)

Example 20 with IRepositoryNodeConfiguration

use of org.talend.mdm.repository.core.IRepositoryNodeConfiguration in project tmdm-studio-se by Talend.

the class ImportServerObjectWizard method doImport.

public List<String> doImport(Object[] objs, IProgressMonitor monitor) {
    monitor.beginTask(Messages.Import_Objects, objs.length);
    List<String> importedIds = new LinkedList<String>();
    ImportService.setImporting(true);
    List<Integer> types = new ArrayList<Integer>();
    types.add(TreeObject.CUSTOM_FORM);
    types.add(TreeObject.DATA_CLUSTER);
    types.add(TreeObject.DATA_MODEL);
    types.add(TreeObject.TRANSFORMER);
    types.add(TreeObject.ROUTING_RULE);
    types.add(TreeObject.MENU);
    types.add(TreeObject.ROLE);
    types.add(TreeObject.STORED_PROCEDURE);
    types.add(TreeObject.VIEW);
    types.add(TreeObject.WORKFLOW_PROCESS);
    IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    for (Object obj : objs) {
        try {
            TreeObject treeObj = (TreeObject) obj;
            monitor.subTask(treeObj.getDisplayName());
            String treeObjName = treeObj.getName();
            MDMServerObject eobj = handleSpecialTreeObject(treeObj);
            if (treeObj.getType() == TreeObject.WORKFLOW_PROCESS) {
                continue;
            }
            if (eobj == null) {
                if (!types.contains(treeObj.getType()) || treeObj.getWsObject() == null || ("JCAAdapers".equals(treeObj.getName()) && treeObj.getType() == TreeObject.DATA_CLUSTER)) {
                    // $NON-NLS-1$
                    continue;
                }
                eobj = (MDMServerObject) Bean2EObjUtil.getInstance().convertFromBean2EObj(treeObj.getWsObject(), null);
            }
            eobj.setLastServerName(serverDef.getName());
            ERepositoryObjectType type = RepositoryQueryService.getRepositoryObjectType(treeObj.getType());
            String uniqueName = getUniqueName(treeObj, treeObjName);
            MDMServerObjectItem item = RepositoryQueryService.findServerObjectItemByNameWithDeleted(type, uniqueName, true);
            if (item != null) {
                if (!isOverrideAll) {
                    int result = isOveride(treeObj.getName(), TreeObject.getTypeName(treeObj.getType()));
                    if (result == IDialogConstants.CANCEL_ID) {
                        ImportService.setImporting(false);
                        return importedIds;
                    }
                    if (result == IDialogConstants.YES_TO_ALL_ID) {
                        isOverrideAll = true;
                    }
                    if (result == IDialogConstants.NO_ID) {
                        break;
                    }
                }
                if (!RepositoryResourceUtil.isLockedItem(item)) {
                    try {
                        factory.lock(item);
                    } catch (PersistenceException e1) {
                        log.error(e1.getMessage(), e1);
                    } catch (LoginException e1) {
                        log.error(e1.getMessage(), e1);
                    }
                    item.setMDMServerObject(eobj);
                    item.getState().setDeleted(false);
                    // save
                    RepositoryResourceUtil.saveItem(item, false);
                    try {
                        factory.unlock(item);
                    } catch (PersistenceException e) {
                        log.error(e.getMessage(), e);
                    } catch (LoginException e) {
                        log.error(e.getMessage(), e);
                    }
                    importedIds.add(item.getProperty().getId());
                }
                CommandManager.getInstance().removeCommandStack(item.getProperty().getId());
            } else {
                IRepositoryNodeConfiguration config = RepositoryNodeConfigurationManager.getConfiguration(type);
                item = (MDMServerObjectItem) config.getResourceProvider().createNewItem(type);
                item.setMDMServerObject(eobj);
                ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
                itemState.setPath(caculatePath(treeObj));
                handlePath(itemState, type);
                item.setState(itemState);
                String version = getVersion(treeObj);
                if (RepositoryResourceUtil.createItem(item, uniqueName, version, false, false)) {
                    importedIds.add(item.getProperty().getId());
                }
            }
        } catch (IOException e) {
            log.error(e.getMessage(), e);
        }
        monitor.worked(1);
    }
    ImportService.setImporting(false);
    monitor.done();
    return importedIds;
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) ArrayList(java.util.ArrayList) IOException(java.io.IOException) LinkedList(java.util.LinkedList) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) TreeObject(com.amalto.workbench.models.TreeObject) LoginException(org.talend.commons.exception.LoginException) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TreeObject(com.amalto.workbench.models.TreeObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Aggregations

IRepositoryNodeConfiguration (org.talend.mdm.repository.core.IRepositoryNodeConfiguration)24 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 IRepositoryNodeResourceProvider (org.talend.mdm.repository.core.IRepositoryNodeResourceProvider)9 Item (org.talend.core.model.properties.Item)8 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)8 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)8 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)6 RepositoryContext (org.talend.core.context.RepositoryContext)5 RecycleBinNodeConfiguration (org.talend.mdm.repository.core.impl.recyclebin.RecycleBinNodeConfiguration)5 PersistenceException (org.talend.commons.exception.PersistenceException)4 Property (org.talend.core.model.properties.Property)4 User (org.talend.core.model.properties.User)4 ResourceBundle (java.util.ResourceBundle)3 ImageRegistry (org.eclipse.jface.resource.ImageRegistry)3 Before (org.junit.Before)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 LoginException (org.talend.commons.exception.LoginException)3 Project (org.talend.core.model.general.Project)3 IRepositoryFactory (org.talend.core.repository.model.IRepositoryFactory)3