Search in sources :

Example 96 with IProxyRepositoryFactory

use of org.talend.repository.model.IProxyRepositoryFactory in project tmdm-studio-se by Talend.

the class RenameProcessAction method moveToOtherTypeNode.

public void moveToOtherTypeNode(IRepositoryViewObject parent, IRepositoryViewObject viewObj) {
    MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
    waitSomeTime(viewObj);
    IProxyRepositoryFactory factory = getFactory();
    try {
        if (factory.isEditableAndLockIfPossible(item)) {
            String path = item.getState().getPath();
            IPath ipath = new Path(path);
            factory.moveObject(viewObj, ipath);
            IRepositoryViewObject iRepositoryViewObject = ContainerCacheService.get(viewObj.getRepositoryObjectType(), path);
            commonViewer.refresh(parent);
            commonViewer.refresh(iRepositoryViewObject);
        }
    } catch (PersistenceException e) {
        log.error(e.getMessage(), e);
    } catch (BusinessException 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 : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) BusinessException(org.talend.commons.exception.BusinessException) IPath(org.eclipse.core.runtime.IPath) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 97 with IProxyRepositoryFactory

use of org.talend.repository.model.IProxyRepositoryFactory in project tmdm-studio-se by Talend.

the class MDMEditViewProcessPropertyAction method moveToOtherTypeNode.

private void moveToOtherTypeNode(IRepositoryViewObject viewObj, String oldPath, String newPath) {
    MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
    item.getState().setPath(newPath);
    waitSomeTime(viewObj);
    IProxyRepositoryFactory factory = getFactory();
    try {
        if (factory.isEditableAndLockIfPossible(item)) {
            IPath ipath = new Path(newPath);
            factory.moveObject(viewObj, ipath);
            ERepositoryObjectType type = viewObj.getRepositoryObjectType();
            refreshTree(type, oldPath);
            refreshTree(type, newPath);
        }
    } catch (PersistenceException e) {
        log.error(e.getMessage(), e);
    } catch (BusinessException e) {
        log.error(e.getMessage(), e);
    } finally {
        unlockItem(item);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) BusinessException(org.talend.commons.exception.BusinessException) IPath(org.eclipse.core.runtime.IPath) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 98 with IProxyRepositoryFactory

use of org.talend.repository.model.IProxyRepositoryFactory in project tmdm-studio-se by Talend.

the class NewDataModelAction method run.

public void run(IIntroSite site, Properties params) {
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (factory.isUserReadOnlyOnCurrentProject()) {
        MessageDialog.openWarning(null, Messages.NewDataModelAction_UserAuthority, Messages.NewDataModelAction_CanNotCreateModel);
    } else {
        PlatformUI.getWorkbench().getIntroManager().closeIntro(PlatformUI.getWorkbench().getIntroManager().getIntro());
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (null == workbenchWindow) {
            return;
        }
        IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
        if (null == workbenchPage) {
            return;
        }
        IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
        if (!IBrandingConfiguration.PERSPECTIVE_MDM_ID.equals(currentPerspective.getId())) {
            // show mdm perspective
            try {
                workbenchWindow.getWorkbench().showPerspective(IBrandingConfiguration.PERSPECTIVE_MDM_ID, workbenchWindow);
                workbenchPage = workbenchWindow.getActivePage();
            } catch (WorkbenchException e) {
                ExceptionHandler.process(e);
                return;
            }
        }
        // 
        // $NON-NLS-1$
        IRepositoryViewObject folderViewObj = ContainerCacheService.get(IServerObjectRepositoryType.TYPE_DATAMODEL, "");
        selectObj = folderViewObj;
        if (folderViewObj != null && folderViewObj instanceof FolderRepositoryObject) {
            Item pItem = folderViewObj.getProperty().getItem();
            if (pItem instanceof ContainerItem) {
                setParentItem((ContainerItem) pItem);
            }
        }
        run();
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) WSDataModelItem(org.talend.mdm.repository.model.mdmproperties.WSDataModelItem) Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) WorkbenchException(org.eclipse.ui.WorkbenchException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 99 with IProxyRepositoryFactory

use of org.talend.repository.model.IProxyRepositoryFactory in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method removeViewObjectPhysically.

public static void removeViewObjectPhysically(ERepositoryObjectType type, String name, String version, String path) {
    if (type == null || name == null) {
        throw new IllegalArgumentException();
    }
    if (version == null) {
        version = VersionUtils.DEFAULT_VERSION;
    }
    if (path == null) {
        // $NON-NLS-1$
        path = "";
    }
    try {
        IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
        for (IRepositoryViewObject viewObj : factory.getAll(type)) {
            Property property = viewObj.getProperty();
            String itemPath = property.getItem().getState().getPath();
            if (itemPath.equals(path) && property.getLabel().equals(name) && property.getVersion().equals(version)) {
                factory.deleteObjectPhysical(viewObj, version);
                return;
            }
        }
    } catch (PersistenceException e) {
        log.error(e.getMessage(), e);
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 100 with IProxyRepositoryFactory

use of org.talend.repository.model.IProxyRepositoryFactory in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method isLockedAndEdited.

public static boolean isLockedAndEdited(IRepositoryViewObject viewObj) {
    IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    ERepositoryStatus status = factory.getStatus(viewObj);
    if (status == ERepositoryStatus.LOCK_BY_OTHER) {
        return true;
    } else if (status == ERepositoryStatus.LOCK_BY_USER) {
        IEditorReference openRef = RepositoryResourceUtil.isOpenedInEditor(viewObj);
        return openRef != null;
    }
    return false;
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IEditorReference(org.eclipse.ui.IEditorReference) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Aggregations

IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)251 PersistenceException (org.talend.commons.exception.PersistenceException)154 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)96 Item (org.talend.core.model.properties.Item)67 Property (org.talend.core.model.properties.Property)58 ArrayList (java.util.ArrayList)42 ConnectionItem (org.talend.core.model.properties.ConnectionItem)34 RepositoryNode (org.talend.repository.model.RepositoryNode)32 ProcessItem (org.talend.core.model.properties.ProcessItem)29 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)28 CoreException (org.eclipse.core.runtime.CoreException)23 LoginException (org.talend.commons.exception.LoginException)22 IRepositoryService (org.talend.repository.model.IRepositoryService)22 ERepositoryStatus (org.talend.commons.runtime.model.repository.ERepositoryStatus)21 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)21 IElementParameter (org.talend.core.model.process.IElementParameter)21 Connection (org.talend.core.model.metadata.builder.connection.Connection)20 List (java.util.List)18 IFile (org.eclipse.core.resources.IFile)18 Project (org.talend.core.model.general.Project)18