Search in sources :

Example 1 with WSRootRepositoryObject

use of org.talend.mdm.repository.models.WSRootRepositoryObject in project tmdm-studio-se by Talend.

the class CopyAction method doRun.

protected void doRun() {
    ITreeSelection selection = (ITreeSelection) getStructuredSelection();
    List<TreePath> paths = new ArrayList<TreePath>(selection.getPaths().length);
    for (TreePath path : selection.getPaths()) {
        Object lastObj = path.getLastSegment();
        if (lastObj instanceof WSRootRepositoryObject) {
            continue;
        }
        if (lastObj instanceof FolderRepositoryObject) {
            continue;
        }
        paths.add(path);
    }
    selection = new TreeSelection(paths.toArray(new TreePath[] {}));
    LocalSelectionTransfer.getTransfer().setSelection(selection);
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) TreePath(org.eclipse.jface.viewers.TreePath) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ArrayList(java.util.ArrayList) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 2 with WSRootRepositoryObject

use of org.talend.mdm.repository.models.WSRootRepositoryObject in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method assertViewObject.

public static IRepositoryViewObject assertViewObject(IRepositoryViewObject viewObj) {
    if (viewObj == null) {
        throw new IllegalArgumentException();
    }
    if (viewObj instanceof IRepositoryViewObject && !(viewObj instanceof FolderRepositoryObject || viewObj instanceof WSRootRepositoryObject) && viewObj instanceof RepositoryObject) {
        boolean reload = false;
        Property property = viewObj.getProperty();
        if (property != null) {
            Item item = property.getItem();
            Resource eResource = item.eResource();
            reload = eResource == null || eResource.getResourceSet() == null;
        } else {
            reload = true;
        }
        if (reload) {
            IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
            try {
                IRepositoryViewObject newViewObj = factory.getLastVersion(viewObj.getId());
                property = viewObj.getProperty();
                if (property != null) {
                    Item item = property.getItem();
                    Resource eResource = item.eResource();
                    reload = eResource == null || eResource.getResourceSet() == null;
                    if (reload) {
                        if (property.eResource() != null && property.eResource().getURI() != null) {
                            property = factory.reload(property);
                            newViewObj = new RepositoryViewObject(property);
                        } else {
                            log.error(// $NON-NLS-1$
                            "Can not reload property " + property.getLabel() + // $NON-NLS-1$
                            ", because property.eResource is null or eResource.getURI is null");
                        }
                    }
                }
                if (newViewObj != null) {
                    ContainerCacheService.put(newViewObj);
                    return newViewObj;
                }
            } catch (PersistenceException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
    return viewObj;
}
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) RepositoryObject(org.talend.core.model.repository.RepositoryObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Resource(org.eclipse.emf.ecore.resource.Resource) IResource(org.eclipse.core.resources.IResource) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 3 with WSRootRepositoryObject

use of org.talend.mdm.repository.models.WSRootRepositoryObject in project tmdm-studio-se by Talend.

the class OpenObjectAction method doOpen.

public boolean doOpen() {
    List<Object> sels = getSelectedObject();
    if (selObjects != null) {
        sels = selObjects;
    }
    if (sels.isEmpty()) {
        return false;
    }
    Object obj = sels.get(0);
    if (obj instanceof IRepositoryViewObject) {
        if (obj instanceof WSRootRepositoryObject) {
            return false;
        }
        IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
        Item item = viewObject.getProperty().getItem();
        if (item instanceof ContainerItem) {
            if (viewObject.getRepositoryObjectType().equals(IServerObjectRepositoryType.TYPE_SERVICECONFIGURATION)) {
                // service
                boolean checkMissingJar = MissingJarService.getInstance().checkMissingJar(true);
                if (!checkMissingJar) {
                    return false;
                }
                // configuration
                MDMServerDef serverDef = openServerDialog(null);
                openServiceConfig(serverDef);
            } else {
                getCommonViewer().expandToLevel(obj, 1);
            }
        } else {
            IEditorReference editorRef = RepositoryResourceUtil.isOpenedInEditor(viewObject);
            if (editorRef != null) {
                if (page == null) {
                    page = getCommonViewer().getCommonNavigator().getSite().getWorkbenchWindow().getActivePage();
                }
                if (page != null) {
                    page.bringToTop(editorRef.getPart(false));
                }
                if (marker != null) {
                    IDE.gotoMarker(editorRef.getEditor(true), marker);
                }
                return false;
            } else {
                openItem(viewObject);
                return true;
            }
        }
    }
    return true;
}
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) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IEditorReference(org.eclipse.ui.IEditorReference) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) TreeObject(com.amalto.workbench.models.TreeObject) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject)

Example 4 with WSRootRepositoryObject

use of org.talend.mdm.repository.models.WSRootRepositoryObject in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method adapt2ResourceElement.

public static Object[] adapt2ResourceElement(IRepositoryViewObject viewObj) {
    if (viewObj == null) {
        return null;
    }
    try {
        if (viewObj instanceof WSRootRepositoryObject) {
            Project project = ProjectManager.getInstance().getCurrentProject();
            IProject prj = ResourceUtils.getProject(project);
            return new Object[] { prj };
        } else {
            ERepositoryObjectType type = viewObj.getRepositoryObjectType();
            if (viewObj instanceof FolderRepositoryObject) {
                if (type == IServerObjectRepositoryType.TYPE_EVENTMANAGER) {
                    return new Object[] { getFolder(IServerObjectRepositoryType.TYPE_TRANSFORMERV2), getFolder(IServerObjectRepositoryType.TYPE_ROUTINGRULE) };
                } else {
                    return new Object[] { getFolder(viewObj) };
                }
            } else {
                Item item = viewObj.getProperty().getItem();
                // $NON-NLS-1$
                IFile itemFile = findReferenceFile(type, item, "item");
                if (type == IServerObjectRepositoryType.TYPE_DATAMODEL) {
                    // $NON-NLS-1$
                    IFile xsdFile = findReferenceFile(type, item, "xsd");
                    return new Object[] { xsdFile, itemFile };
                } else if (type == IServerObjectRepositoryType.TYPE_WORKFLOW) {
                    // $NON-NLS-1$
                    IFile configFile = findReferenceFile(type, item, "conf");
                    return new Object[] { configFile };
                } else {
                    return new Object[] { itemFile };
                }
            }
        }
    } catch (PersistenceException e) {
        log.error(e.getMessage(), e);
    }
    return null;
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) 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) IFile(org.eclipse.core.resources.IFile) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProject(org.eclipse.core.resources.IProject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 5 with WSRootRepositoryObject

use of org.talend.mdm.repository.models.WSRootRepositoryObject in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method getCategoryViewObjectsWithRecycle.

public static IRepositoryViewObject[] getCategoryViewObjectsWithRecycle() {
    if (rootViewObj == null) {
        // 
        rootViewObj = null;
        Property prop = PropertiesFactory.eINSTANCE.createProperty();
        prop.setId(EcoreUtil.generateUUID());
        ItemState state = PropertiesFactory.eINSTANCE.createItemState();
        WorkspaceRootItem item = MdmpropertiesFactory.eINSTANCE.createWorkspaceRootItem();
        item.setState(state);
        prop.setItem(item);
        rootViewObj = new WSRootRepositoryObject(prop);
        // 
        IRepositoryViewObject[] cvos = getCategoryViewObjects();
        List<IRepositoryViewObject> newViewObjs = rootViewObj.getChildren();
        for (IRepositoryViewObject viewObj : cvos) {
            newViewObjs.add(viewObj);
        }
        // 
        newViewObjs.add(getCategoryViewObject(RepositoryNodeConfigurationManager.getRecycleBinNodeConfiguration()));
    }
    return new IRepositoryViewObject[] { rootViewObj };
}
Also used : WorkspaceRootItem(org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem) ItemState(org.talend.core.model.properties.ItemState) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject)

Aggregations

IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 WSRootRepositoryObject (org.talend.mdm.repository.models.WSRootRepositoryObject)5 Item (org.talend.core.model.properties.Item)3 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)3 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)3 WorkspaceRootItem (org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem)3 FolderRepositoryObject (org.talend.mdm.repository.models.FolderRepositoryObject)3 PersistenceException (org.talend.commons.exception.PersistenceException)2 BusinessProcessItem (org.talend.core.model.properties.BusinessProcessItem)2 FolderItem (org.talend.core.model.properties.FolderItem)2 Property (org.talend.core.model.properties.Property)2 RepositoryObject (org.talend.core.model.repository.RepositoryObject)2 RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)2 TDQMatchRuleItem (org.talend.dataquality.properties.TDQMatchRuleItem)2 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)2 TreeObject (com.amalto.workbench.models.TreeObject)1 ArrayList (java.util.ArrayList)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1