Search in sources :

Example 41 with MDMServerObjectItem

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

the class AbstractNodeCheckTreeViewer method isExist.

private boolean isExist(TreeObject treeObj) {
    if (treeObj instanceof TreeParent) {
        return false;
    }
    int type = treeObj.getType();
    ERepositoryObjectType rType = RepositoryQueryService.getRepositoryObjectType(type);
    if (rType == null) {
        return false;
    }
    List<IRepositoryViewObject> children = RepositoryResourceUtil.findAllViewObjectsWithDeleted(rType);
    if (children == null) {
        return false;
    }
    String treeObjName = treeObj.getName();
    if (type == TreeObject.PICTURES_RESOURCE) {
        // $NON-NLS-1$
        int index = treeObjName.indexOf("-");
        if (index > 0) {
            treeObjName = treeObjName.substring(index + 1);
        }
    }
    for (IRepositoryViewObject viewObject : children) {
        Item item = viewObject.getProperty().getItem();
        if (item instanceof MDMServerObjectItem) {
            MDMServerObject serverObj = ((MDMServerObjectItem) item).getMDMServerObject();
            String name = serverObj.getName();
            if (type == TreeObject.WORKFLOW_PROCESS) {
                // $NON-NLS-1$
                name = name + "_" + viewObject.getVersion();
            }
            if (type == TreeObject.PICTURES_RESOURCE) {
                // $NON-NLS-1$ //$NON-NLS-2$
                name = name + "_" + viewObject.getVersion() + "." + ((WSResourceE) serverObj).getFileExtension();
            }
            if (serverObj != null && treeObjName.equals(name)) {
                return true;
            }
        }
    }
    return false;
}
Also used : Item(org.talend.core.model.properties.Item) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) TreeParent(com.amalto.workbench.models.TreeParent) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) WSResourceE(org.talend.mdm.repository.model.mdmserverobject.WSResourceE) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 42 with MDMServerObjectItem

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

the class RepositoryQueryService method findAllWorkflowNames.

public static List<String> findAllWorkflowNames() {
    List<IRepositoryViewObject> viewObjects = RepositoryResourceUtil.findAllViewObjects(IServerObjectRepositoryType.TYPE_WORKFLOW);
    List<String> names = new LinkedList<String>();
    if (viewObjects != null) {
        for (IRepositoryViewObject viewObj : viewObjects) {
            Item item = viewObj.getProperty().getItem();
            if (item instanceof MDMServerObjectItem) {
                MDMServerObjectItem serverItem = (MDMServerObjectItem) item;
                // $NON-NLS-1$
                names.add(serverItem.getMDMServerObject().getName() + "_" + item.getProperty().getVersion());
            }
        // names[i]=viewObj.getLabel();
        }
    }
    return names;
}
Also used : Item(org.talend.core.model.properties.Item) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) LinkedList(java.util.LinkedList)

Example 43 with MDMServerObjectItem

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

the class RepositoryQueryService method findAllServerObjectNames.

private static List<String> findAllServerObjectNames(ERepositoryObjectType type) {
    List<IRepositoryViewObject> viewObjects = RepositoryResourceUtil.findAllViewObjects(type);
    List<String> names = new LinkedList<String>();
    if (viewObjects != null) {
        for (IRepositoryViewObject viewObj : viewObjects) {
            Item item = viewObj.getProperty().getItem();
            if (item instanceof MDMServerObjectItem) {
                String name = ((MDMServerObjectItem) item).getMDMServerObject().getName();
                if (name != null) {
                    names.add(name);
                } else {
                    names.add(viewObj.getLabel());
                }
            }
        // names[i]=viewObj.getLabel();
        }
    }
    return names;
}
Also used : Item(org.talend.core.model.properties.Item) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) LinkedList(java.util.LinkedList)

Example 44 with MDMServerObjectItem

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

the class RepositoryQueryService method findAllCustomFormPks.

public static List<String> findAllCustomFormPks() {
    List<IRepositoryViewObject> viewObjects = RepositoryResourceUtil.findAllViewObjects(IServerObjectRepositoryType.TYPE_CUSTOM_FORM);
    List<String> names = new LinkedList<String>();
    if (viewObjects != null) {
        for (IRepositoryViewObject viewObj : viewObjects) {
            Item item = viewObj.getProperty().getItem();
            if (item instanceof MDMServerObjectItem) {
                MDMServerObject sObject = ((MDMServerObjectItem) item).getMDMServerObject();
                if (sObject instanceof WSCustomFormE) {
                    WSCustomFormE sForm = (WSCustomFormE) sObject;
                    String name = sForm.getDatamodel() + IConstants.ITEM_PK_SPLIT + sForm.getEntity() + IConstants.ITEM_PK_SPLIT + sForm.getName();
                    if (name != null) {
                        names.add(name);
                    } else {
                        names.add(viewObj.getLabel());
                    }
                }
            }
        // names[i]=viewObj.getLabel();
        }
    }
    return names;
}
Also used : WSCustomFormE(org.talend.mdm.repository.model.mdmserverobject.WSCustomFormE) Item(org.talend.core.model.properties.Item) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) LinkedList(java.util.LinkedList) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)

Example 45 with MDMServerObjectItem

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

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