Search in sources :

Example 16 with ERepositoryStatus

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

the class JobletUtil method lockByOthers.

// public void reloadJobletComponent(IProcess2 process){
// IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
// IJobletProviderService.class);
// if (service != null) {
// process.get
// service.reloadJobletProcess(this);
// }
// }
public boolean lockByOthers(Item item) {
    IProxyRepositoryService service = (IProxyRepositoryService) GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class);
    IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
    ERepositoryStatus repositoryStatus = factory.getStatus(item);
    if (repositoryStatus == ERepositoryStatus.LOCK_BY_OTHER) {
        return true;
    }
    return false;
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IProxyRepositoryService(org.talend.repository.model.IProxyRepositoryService) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 17 with ERepositoryStatus

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

the class ImportItemWizardPage method populateItems.

/**
     * DOC hcw Comment method "populateItems".
     */
private void populateItems() {
    selectedItems.clear();
    final Collection<ItemRecord> items = new ArrayList<ItemRecord>();
    IRunnableWithProgress op = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            repositoryUtil.clearAllData();
            items.addAll(totalItemRecords = repositoryUtil.populateItems(manager, overwrite, monitor));
        }
    };
    try {
        new ProgressMonitorDialog(getShell()).run(true, true, op);
    } catch (Exception e) {
    // ignore me
    }
    errors.clear();
    for (ItemRecord itemRecord : items) {
        // bug 21738
        if (itemRecord.getExistingItemWithSameId() != null && itemRecord.getExistingItemWithSameId() instanceof RepositoryViewObject) {
            RepositoryViewObject reObject = (RepositoryViewObject) itemRecord.getExistingItemWithSameId();
            if (itemRecord.getProperty() != null && reObject != null) {
                if (itemRecord.getProperty().getId().equals(reObject.getId()) && itemRecord.getProperty().getLabel().equals(reObject.getLabel()) && itemRecord.getProperty().getVersion().equals(reObject.getVersion())) {
                    for (String error : itemRecord.getErrors()) {
                        //$NON-NLS-1$ //$NON-NLS-2$
                        errors.add("'" + itemRecord.getItemName() + "' " + error);
                    }
                } else if (itemRecord.getProperty().getId().equals(reObject.getId()) && itemRecord.getProperty().getLabel().equals(reObject.getLabel()) && !itemRecord.getProperty().getVersion().equals(reObject.getVersion())) {
                    for (String error : itemRecord.getErrors()) {
                        //$NON-NLS-1$ //$NON-NLS-2$
                        errors.add("'" + itemRecord.getItemName() + "' " + Messages.getString("ImportItemWizardPage.ErrorsMessage", reObject.getVersion()));
                    }
                } else {
                    // TDI-21399,TDI-21401
                    // if item is locked, cannot overwrite
                    ERepositoryStatus status = reObject.getRepositoryStatus();
                    if (status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.LOCK_BY_USER) {
                        for (String error : itemRecord.getErrors()) {
                            //$NON-NLS-1$ //$NON-NLS-2$
                            errors.add("'" + itemRecord.getItemName() + "' " + error);
                        }
                    }
                }
            }
        } else {
            if (itemRecord.getProperty() != null) {
                Item item = itemRecord.getProperty().getItem();
                if (item != null && (item instanceof JobDocumentationItem || item instanceof JobletDocumentationItem)) {
                    continue;
                }
                for (String error : itemRecord.getErrors()) {
                    //$NON-NLS-1$ //$NON-NLS-2$
                    errors.add("'" + itemRecord.getItemName() + "' " + error);
                }
            }
        }
    }
    if (errorsList != null) {
        errorsList.refresh();
    }
    selectedItems.addAll(items);
    checkTreeViewer.refresh(true);
    checkTreeViewer.expandAll();
    filteredCheckboxTree.resetCheckedElements();
    checkValidItems();
    updateFinishStatus();
// see feature 0004170: Unselect all items to import
// itemsList.setCheckedElements(checkValidItems());
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) ZipException(java.util.zip.ZipException) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TarException(org.eclipse.ui.internal.wizards.datatransfer.TarException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) JobletDocumentationItem(org.talend.core.model.properties.JobletDocumentationItem) JobDocumentationItem(org.talend.core.model.properties.JobDocumentationItem) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) TreeItem(org.eclipse.swt.widgets.TreeItem) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) JobDocumentationItem(org.talend.core.model.properties.JobDocumentationItem) JobletDocumentationItem(org.talend.core.model.properties.JobletDocumentationItem) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 18 with ERepositoryStatus

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

the class RouteResourceEditorUtil method isReadOnly.

public static boolean isReadOnly(IRepositoryNode node) {
    IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
    IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
    /*
		 * if user is readonly , then set enable as false
		 */
    if (repFactory.isUserReadOnlyOnCurrentProject()) {
        return true;
    }
    // if it's not in current project, then it's disable
    if (!ProjectManager.getInstance().isInCurrentMainProject(node)) {
        return true;
    }
    // if it's locked by others, then it's disable
    IRepositoryViewObject object = node.getObject();
    if (object == null) {
        return false;
    }
    Property property = object.getProperty();
    if (property == null) {
        return false;
    }
    Item item = property.getItem();
    if (item == null) {
        return false;
    }
    ERepositoryStatus status = repFactory.getStatus(item);
    if (ERepositoryStatus.LOCK_BY_OTHER.equals(status) || ERepositoryStatus.DELETED.equals(status)) {
        return true;
    }
    if (!isLatestVersion(property)) {
        return true;
    }
    return false;
}
Also used : RouteResourceItem(org.talend.camel.core.model.camelProperties.RouteResourceItem) Item(org.talend.core.model.properties.Item) ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IRepositoryService(org.talend.repository.model.IRepositoryService)

Example 19 with ERepositoryStatus

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

the class ConfigExternalLibPage method isReadOnly.

public boolean isReadOnly() {
    boolean readonly = false;
    IProxyRepositoryFactory repFactory = ProxyRepositoryFactory.getInstance();
    ERepositoryStatus status = repFactory.getStatus(getSelectedRepositoryNode().getObject());
    if (!repFactory.isPotentiallyEditable(getSelectedRepositoryNode().getObject()) || status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.LOCK_BY_USER) {
        readonly = true;
    }
    return readonly;
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 20 with ERepositoryStatus

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

the class TalendImportUtil method importItems.

public static boolean importItems(String zipPath, IProgressMonitor monitor, final boolean overwrite, final boolean openThem, boolean needMigrationTask) throws IOException {
    // File srcFile = new File(zipPath);
    ZipFile srcZipFile = new ZipFile(zipPath);
    final ImportExportHandlersManager importManager = new ImportExportHandlersManager();
    final ResourcesManager resourcesManager = ResourcesManagerFactory.getInstance().createResourcesManager(srcZipFile);
    // resourcesManager.collectPath2Object(srcFile);
    resourcesManager.collectPath2Object(srcZipFile);
    final List<ImportItem> items = populateItems(importManager, resourcesManager, monitor, overwrite);
    final List<String> itemIds = new ArrayList<String>();
    try {
        for (ImportItem itemRecord : items) {
            Item item = itemRecord.getProperty().getItem();
            if (item instanceof ProcessItem) {
                // only select jobs
                itemIds.add(item.getProperty().getId());
            }
            IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            if (item.getState().isLocked()) {
                factory.unlock(item);
            }
            ERepositoryStatus status = factory.getStatus(item);
            if (status != null && status == ERepositoryStatus.LOCK_BY_USER) {
                factory.unlock(item);
            }
            if (!needMigrationTask) {
                itemRecord.setMigrationTasksToApply(null);
            }
        }
        // nodesBuilder.getAllImportItemRecords(), null);
        if (items != null && !items.isEmpty()) {
            importManager.importItemRecords(monitor, resourcesManager, items, overwrite, nodesBuilder.getAllImportItemRecords(), null);
        }
    } catch (Exception e) {
        CommonExceptionHandler.process(e);
    } finally {
        // clean
        if (resourcesManager != null) {
            resourcesManager.closeResource();
        }
        nodesBuilder.clear();
    }
    return true;
}
Also used : ImportExportHandlersManager(org.talend.repository.items.importexport.handlers.ImportExportHandlersManager) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) ArrayList(java.util.ArrayList) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) ZipFile(java.util.zip.ZipFile) ProcessItem(org.talend.core.model.properties.ProcessItem) ResourcesManager(org.talend.repository.items.importexport.manager.ResourcesManager) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

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