Search in sources :

Example 11 with ERepositoryStatus

use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method isLockedViewObject.

public static boolean isLockedViewObject(IRepositoryViewObject viewObj) {
    IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    ERepositoryStatus status = factory.getStatus(viewObj);
    return status == ERepositoryStatus.LOCK_BY_USER || status == ERepositoryStatus.LOCK_BY_OTHER;
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 12 with ERepositoryStatus

use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tmdm-studio-se by Talend.

the class RepositoryResourceUtil method isLockedItem.

public static boolean isLockedItem(Item item) {
    IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    ERepositoryStatus status = factory.getStatus(item);
    return status == ERepositoryStatus.LOCK_BY_USER || status == ERepositoryStatus.LOCK_BY_OTHER;
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 13 with ERepositoryStatus

use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tdq-studio-se by Talend.

the class FileSystemImportWriter method removeLockStatus.

/**
 * when the item's status is locked, change to unlocked.
 *
 * @param property
 */
private void removeLockStatus(Property property) {
    Item item = property.getItem();
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    ERepositoryStatus status = factory.getStatus(item);
    if (status != null && status == ERepositoryStatus.LOCK_BY_USER) {
        try {
            factory.unlock(item);
            // after unlock, reload the resource.
            EMFSharedResources.getInstance().reloadResource(getUri(property));
        } catch (PersistenceException e) {
            log.error(e, e);
        } catch (LoginException e) {
            log.error(e, e);
        }
    }
}
Also used : TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) Item(org.talend.core.model.properties.Item) TDQItem(org.talend.core.model.properties.TDQItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 14 with ERepositoryStatus

use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tesb-studio-se by Talend.

the class AssignJobAction method init.

@Override
protected void init(RepositoryNode node) {
    ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
    if (!currentNodeType.equals(nodeType)) {
        return;
    }
    IProxyRepositoryFactory proxyFactory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
    try {
        proxyFactory.updateLockStatus();
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    IRepositoryViewObject repositoryViewObject = node.getObject();
    ERepositoryStatus status = proxyFactory.getStatus(repositoryViewObject);
    if (!status.isEditable() && !status.isPotentiallyEditable()) {
        setEnabled(false);
    } else {
        // not enabled if the operation doesn't define in binding
        if (!WSDLUtils.isOperationInBinding(node)) {
            setEnabled(false);
            return;
        }
        setEnabled(true);
    }
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 15 with ERepositoryStatus

use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tdi-studio-se by Talend.

the class JobletUtil method isRed.

public boolean isRed(AbstractJobletContainer jobletContainer) {
    IProcess2 jobletProcess = (IProcess2) jobletContainer.getNode().getComponent().getProcess();
    if (jobletProcess == null) {
        return false;
    }
    ERepositoryStatus status = ProxyRepositoryFactory.getInstance().getStatus(jobletProcess.getProperty().getItem());
    if (status == ERepositoryStatus.LOCK_BY_OTHER) {
        return true;
    }
    IEditorPart[] editors = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getDirtyEditors();
    if (editors.length <= 0) {
        return false;
    }
    for (IEditorPart editor : editors) {
        if (editor.getEditorInput() instanceof RepositoryEditorInput) {
            RepositoryEditorInput editorInput = (RepositoryEditorInput) editor.getEditorInput();
            String jobletId = editorInput.getId();
            if (jobletId.equals(jobletProcess.getId())) {
                return true;
            }
        }
    }
    return false;
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IProcess2(org.talend.core.model.process.IProcess2) IEditorPart(org.eclipse.ui.IEditorPart)

Aggregations

ERepositoryStatus (org.talend.commons.runtime.model.repository.ERepositoryStatus)34 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)21 PersistenceException (org.talend.commons.exception.PersistenceException)14 Item (org.talend.core.model.properties.Item)12 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)12 InvocationTargetException (java.lang.reflect.InvocationTargetException)7 CoreException (org.eclipse.core.runtime.CoreException)7 LoginException (org.talend.commons.exception.LoginException)7 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)7 RepositoryNode (org.talend.repository.model.RepositoryNode)7 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)6 ProcessItem (org.talend.core.model.properties.ProcessItem)6 IOException (java.io.IOException)5 PartInitException (org.eclipse.ui.PartInitException)5 IRepositoryService (org.talend.repository.model.IRepositoryService)5 ArrayList (java.util.ArrayList)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 IProcess2 (org.talend.core.model.process.IProcess2)3