Search in sources :

Example 21 with IRepositoryNodeConfiguration

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

the class RepositoryViewObjectCheckedWidget method initInput.

/**
 * DOC hbhong Comment method "initInput".
 *
 * @param type
 * @return
 */
private IRepositoryViewObject[] initInput(ERepositoryObjectType type) {
    if (type != null) {
        IRepositoryViewObject[] elements = RepositoryResourceUtil.getCategoryViewObjects(type);
        List<IRepositoryViewObject> objs = new ArrayList<IRepositoryViewObject>();
        objs.addAll(Arrays.asList(elements));
        // missing transformer2, routingrule
        if (type.getKey().equals(IServerObjectRepositoryType.TYPE_TRANSFORMERV2.getKey()) || type.getKey().equals(IServerObjectRepositoryType.TYPE_ROUTINGRULE.getKey())) {
            IRepositoryNodeConfiguration typeConf = RepositoryNodeConfigurationManager.getConfiguration(type);
            addCategoryViewObject(objs, typeConf);
        }
        if (type.getKey().equals(IServerObjectRepositoryType.TYPE_EVENTMANAGER.getKey())) {
            IRepositoryNodeConfiguration processConf = RepositoryNodeConfigurationManager.getConfiguration(IServerObjectRepositoryType.TYPE_TRANSFORMERV2);
            IRepositoryNodeConfiguration triggerConf = RepositoryNodeConfigurationManager.getConfiguration(IServerObjectRepositoryType.TYPE_ROUTINGRULE);
            addCategoryViewObject(objs, processConf);
            addCategoryViewObject(objs, triggerConf);
        }
        return objs.toArray(new IRepositoryViewObject[0]);
    } else {
        IRepositoryViewObject[] elements = RepositoryResourceUtil.getCategoryViewObjects();
        List<IRepositoryViewObject> objs = new ArrayList<IRepositoryViewObject>();
        for (IRepositoryViewObject folderObj : elements) {
            ERepositoryObjectType objType = folderObj.getRepositoryObjectType();
            if (objType == IServerObjectRepositoryType.TYPE_EVENTMANAGER) {
                IRepositoryNodeConfiguration processConf = RepositoryNodeConfigurationManager.getConfiguration(IServerObjectRepositoryType.TYPE_TRANSFORMERV2);
                IRepositoryNodeConfiguration triggerConf = RepositoryNodeConfigurationManager.getConfiguration(IServerObjectRepositoryType.TYPE_ROUTINGRULE);
                addCategoryViewObject(objs, processConf);
                addCategoryViewObject(objs, triggerConf);
            } else if (objType != IServerObjectRepositoryType.TYPE_MATCH_RULE) {
                objs.add(folderObj);
            }
        }
        Collections.sort(objs, new Comparator() {

            public int compare(Object o1, Object o2) {
                String name1 = ((IRepositoryViewObject) o1).getRepositoryObjectType().getLabel();
                String name2 = ((IRepositoryViewObject) o2).getRepositoryObjectType().getLabel();
                return name1.compareTo(name2);
            }
        });
        return objs.toArray(new IRepositoryViewObject[0]);
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ArrayList(java.util.ArrayList) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Comparator(java.util.Comparator)

Example 22 with IRepositoryNodeConfiguration

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

the class OpenObjectAction method openItem.

private void openItem(IRepositoryViewObject viewObject) {
    Item item = viewObject.getProperty().getItem();
    item = RepositoryResourceUtil.assertItem(item);
    IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(item);
    if (configuration != null) {
        IRepositoryNodeActionProvider actionProvider = configuration.getActionProvider();
        if (actionProvider != null) {
            IRepositoryViewEditorInput editorInput = actionProvider.getOpenEditorInput(viewObject);
            if (editorInput != null) {
                if (page == null) {
                    this.page = getCommonViewer().getCommonNavigator().getSite().getWorkbenchWindow().getActivePage();
                }
                // do extra action
                MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
                if (!checkMissingJar(serverObject)) {
                    return;
                }
                boolean selected = doSelectServer(item, editorInput);
                if (!selected) {
                    return;
                }
                try {
                    // svn lock
                    ERepositoryStatus status = factory.getStatus(item);
                    boolean isEditable = factory.isEditableAndLockIfPossible(item);
                    if (isEditable) {
                        getCommonViewer().refresh(viewObject);
                    }
                    // 
                    editorInput.setReadOnly(status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.READ_ONLY || !isEditable);
                    if (!editorInput.isReadOnly()) {
                        editorInput.setReadOnly(item.getState().isDeleted());
                    }
                    updateEditorInputVersionInfo(editorInput, viewObject);
                    activeEditor = this.page.openEditor(editorInput, editorInput.getEditorId());
                    if (marker != null) {
                        IDE.gotoMarker(activeEditor, marker);
                    }
                } catch (PartInitException e) {
                    log.error(e.getMessage(), e);
                }
            } else {
                AbstractRepositoryAction openAction = actionProvider.getOpenAction(viewObject);
                if (openAction != null) {
                    openAction.selectionChanged(getStructuredSelection());
                    openAction.run();
                }
            }
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) AbstractRepositoryAction(org.talend.mdm.repository.core.AbstractRepositoryAction) ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IRepositoryViewEditorInput(org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput) IRepositoryNodeActionProvider(org.talend.mdm.repository.core.IRepositoryNodeActionProvider) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) PartInitException(org.eclipse.ui.PartInitException) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 23 with IRepositoryNodeConfiguration

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

the class RenameObjectAction method doRun.

@Override
protected void doRun() {
    Object obj = getSelectedObject().get(0);
    if (obj instanceof IRepositoryViewObject) {
        IRepositoryViewObject viewObj = (IRepositoryViewObject) obj;
        MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
        MDMServerObject serverObject = item.getMDMServerObject();
        IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(item);
        if (configuration != null) {
            ERepositoryObjectType type = configuration.getResourceProvider().getRepositoryObjectType(item);
            IRepositoryViewObject parentViewObj = ContainerCacheService.get(type, item.getState().getPath());
            try {
                if (serverObject != null) {
                    String oldName = serverObject.getName();
                    String newName = showRenameDlg(type, (ContainerItem) parentViewObj.getProperty().getItem(), oldName);
                    if (newName != null && factory.isEditableAndLockIfPossible(item)) {
                        serverObject.setName(newName);
                        viewObj.getProperty().setLabel(newName);
                        viewObj.getProperty().setDisplayName(newName);
                        factory.save(viewObj.getProperty().getItem(), false);
                        MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(viewObj);
                        if (lastServerDef != null) {
                            CommandManager.getInstance().pushCommand(ICommand.CMD_RENAME, viewObj.getId(), new String[] { oldName, newName });
                        }
                    }
                }
                commonViewer.refresh(obj);
            } catch (PersistenceException e) {
                log.error(e.getMessage(), e);
            } finally {
                try {
                    factory.unlock(item);
                } catch (PersistenceException e) {
                    log.error(e.getMessage(), e);
                } catch (LoginException e) {
                    log.error(e.getMessage(), e);
                }
            }
        }
    }
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) LoginException(org.talend.commons.exception.LoginException) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 24 with IRepositoryNodeConfiguration

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

the class RepositoryResourceUtil method saveItem.

public static void saveItem(Item item, boolean triggerEvent) {
    IRepositoryNodeConfiguration configuration = RepositoryNodeConfigurationManager.getConfiguration(item);
    if (configuration != null) {
        IRepositoryNodeResourceProvider resourceProvider = configuration.getResourceProvider();
        if (resourceProvider.needSaveReferenceFile()) {
            item = assertItem(item);
            resourceProvider.handleReferenceFile(item);
        }
        // save
        IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
        try {
            item = assertItem(item);
            factory.save(item, !triggerEvent);
        } catch (PersistenceException e) {
            log.error(e);
        }
    }
}
Also used : IRepositoryNodeResourceProvider(org.talend.mdm.repository.core.IRepositoryNodeResourceProvider) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryNodeConfiguration(org.talend.mdm.repository.core.IRepositoryNodeConfiguration) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

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