Search in sources :

Example 36 with MDMServerObjectItem

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

the class RepositoryNodeActionProviderAdapter method getOpenEditorInput.

/**
 * The child class can override this method, current implement is adapt to most of MDMServerobject
 */
@Override
public IRepositoryViewEditorInput getOpenEditorInput(IRepositoryViewObject viewObj) {
    Item item = viewObj.getProperty().getItem();
    MDMServerObject serverObject = ((MDMServerObjectItem) item).getMDMServerObject();
    if (serverObject.getType() == TreeObject.DATA_CLUSTER) {
        // Data Cluster
        return new XObjectBrowserInput2(viewObj);
    }
    return new XObjectEditorInput2(viewObj);
}
Also used : 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) XObjectEditorInput2(org.talend.mdm.repository.ui.editors.XObjectEditorInput2) XObjectBrowserInput2(org.talend.mdm.repository.ui.editors.XObjectBrowserInput2) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 37 with MDMServerObjectItem

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

the class ViewActionProvider method getActions.

@Override
public List<AbstractRepositoryAction> getActions(IRepositoryViewObject viewObj) {
    List<AbstractRepositoryAction> actions = super.getActions(viewObj);
    Item item = viewObj.getProperty().getItem();
    String path = item.getState().getPath();
    if (path.isEmpty()) {
        actions.remove(createFolderAction);
    }
    if ((item instanceof ContainerItem) && (path.equals(IPath.SEPARATOR + IViewNodeConstDef.PATH_SEARCHFILTER) || path.equals(IPath.SEPARATOR + IViewNodeConstDef.PATH_WEBFILTER))) {
        actions.remove(removeFromRepositoryAction);
    }
    if (RepositoryResourceUtil.hasContainerItem(viewObj, FolderType.SYSTEM_FOLDER_LITERAL, FolderType.FOLDER_LITERAL)) {
        addAction(actions, addAction, viewObj);
    }
    if (viewObj.getProperty().getItem() instanceof MDMServerObjectItem) {
        int index = actions.indexOf(mdmEditPropertyAction);
        if (index != -1) {
            actions.add(index, editViewProcessPropertyAction);
            actions.remove(mdmEditPropertyAction);
        }
        addAction(actions, renameViewAction, viewObj);
        addAction(actions, browseViewAction, viewObj);
        // deploy
        addAction(actions, deployToAction, viewObj);
        addAction(actions, deployToLastServerAction, viewObj);
        addAction(actions, deployAnotherToAction, viewObj);
        addAction(actions, undeployAction, viewObj);
    }
    addAction(actions, deployAllAction, viewObj);
    return actions;
}
Also used : AbstractRepositoryAction(org.talend.mdm.repository.core.AbstractRepositoryAction) Item(org.talend.core.model.properties.Item) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)

Example 38 with MDMServerObjectItem

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

the class AddBrowseItemsWizardR method modifyRolesWithAttachedBrowseItem.

@Override
protected void modifyRolesWithAttachedBrowseItem(String browseItem, List<Line> roles) {
    for (Line line : roles) {
        List<KeyValue> keyValues = line.keyValues;
        String roleName = keyValues.get(0).value;
        MDMServerObjectItem roleItem = RepositoryQueryService.findServerObjectItemByName(IServerObjectRepositoryType.TYPE_ROLE, roleName);
        if (roleItem != null) {
            CommandManager.getInstance().pushCommand(ICommand.CMD_MODIFY, roleItem.getProperty().getId(), roleItem.getMDMServerObject().getName());
        }
        if (roleItem != null) {
            IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
            if (factory.isEditableAndLockIfPossible(roleItem)) {
                WSRoleE role = ((WSRoleItem) roleItem).getWsRole();
                for (WSRoleSpecificationE spec : role.getSpecification()) {
                    if (spec.getObjectType().equals("View")) {
                        // $NON-NLS-1$
                        EList<WSRoleSpecificationInstanceE> specInstance = spec.getInstance();
                        // 
                        WSRoleSpecificationInstanceE newInstance = MdmserverobjectFactory.eINSTANCE.createWSRoleSpecificationInstanceE();
                        newInstance.setInstanceName(browseItem);
                        // $NON-NLS-1$
                        newInstance.setWritable(keyValues.get(1).value.equals("Read Only") ? false : true);
                        // 
                        specInstance.add(newInstance);
                        // 
                        break;
                    }
                }
                RepositoryResourceUtil.saveItem(roleItem);
            }
            try {
                factory.unlock(roleItem);
            } catch (PersistenceException e) {
                log.error(e.getMessage(), e);
            } catch (LoginException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
}
Also used : KeyValue(com.amalto.workbench.models.KeyValue) WSRoleE(org.talend.mdm.repository.model.mdmserverobject.WSRoleE) WSRoleSpecificationInstanceE(org.talend.mdm.repository.model.mdmserverobject.WSRoleSpecificationInstanceE) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) WSRoleSpecificationE(org.talend.mdm.repository.model.mdmserverobject.WSRoleSpecificationE) Line(com.amalto.workbench.models.Line) WSRoleItem(org.talend.mdm.repository.model.mdmproperties.WSRoleItem) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 39 with MDMServerObjectItem

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

Example 40 with MDMServerObjectItem

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

the class MDMRepositoryViewerSorter method category.

@Override
public int category(Object element) {
    if (element instanceof IRepositoryViewObject) {
        IRepositoryViewObject viewObject = (IRepositoryViewObject) element;
        ERepositoryObjectType repositoryObjectType = viewObject.getRepositoryObjectType();
        if (repositoryObjectType == null)
            return 0;
        if (repositoryObjectType == IServerObjectRepositoryType.TYPE_RECYCLE_BIN) {
            return 2;
        }
        try {
            Item item = viewObject.getProperty().getItem();
            if (item != null) {
                if (item instanceof MDMServerObjectItem) {
                    return 1;
                }
                if (item instanceof ContainerItem) {
                    return SortOrderFactory.getOrder((ContainerItem) item);
                }
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
    return 0;
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Aggregations

MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)50 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)33 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)28 Item (org.talend.core.model.properties.Item)22 Property (org.talend.core.model.properties.Property)15 PersistenceException (org.talend.commons.exception.PersistenceException)13 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)12 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)11 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)10 LoginException (org.talend.commons.exception.LoginException)9 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)9 TreeObject (com.amalto.workbench.models.TreeObject)7 Test (org.junit.Test)7 TMDMService (com.amalto.workbench.webservices.TMDMService)6 LinkedList (java.util.LinkedList)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 BusinessException (org.talend.commons.exception.BusinessException)5 FolderItem (org.talend.core.model.properties.FolderItem)5 ProcessItem (org.talend.core.model.properties.ProcessItem)5 ArrayList (java.util.ArrayList)4