Search in sources :

Example 1 with ERepositoryObjectType

use of org.talend.core.model.repository.ERepositoryObjectType in project tdi-studio-se by Talend.

the class OpenDiagramAction method init.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
     * org.eclipse.jface.viewers.IStructuredSelection)
     */
public void init(TreeViewer viewer, IStructuredSelection selection) {
    boolean enabled = false;
    if (!selection.isEmpty() && selection.size() == 1) {
        Object object = selection.getFirstElement();
        if (object instanceof RepositoryNode) {
            RepositoryNode repositoryNode = (RepositoryNode) object;
            ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
            if (repositoryNode.getType() == RepositoryNode.ENodeType.REPOSITORY_ELEMENT) {
                if (nodeType == ERepositoryObjectType.BUSINESS_PROCESS) {
                    enabled = true;
                }
            }
            if (enabled && (ProxyRepositoryFactory.getInstance().isUserReadOnlyOnCurrentProject() || !ProjectManager.getInstance().isInCurrentMainProject(repositoryNode) || !isLastVersion(repositoryNode))) {
                enabled = false;
            }
            RepositoryNode parent = repositoryNode.getParent();
            if (enabled && parent != null && parent.isBin()) {
                enabled = false;
            }
        }
    }
    setEnabled(enabled);
}
Also used : RepositoryObject(org.talend.core.model.repository.RepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 2 with ERepositoryObjectType

use of org.talend.core.model.repository.ERepositoryObjectType in project tdi-studio-se by Talend.

the class CreateDiagramAction method init.

@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
    // PTODO mhelleboid refactor AContextualAction
    repositoryNode = getRepositoryNode(selection);
    boolean enabled = false;
    if (repositoryNode != null) {
        ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
        if (repositoryNode.getType() == RepositoryNode.ENodeType.SYSTEM_FOLDER || repositoryNode.getType() == RepositoryNode.ENodeType.SIMPLE_FOLDER) {
            if (nodeType == ERepositoryObjectType.BUSINESS_PROCESS) {
                enabled = true;
            }
            if (repositoryNode.getObject() != null && repositoryNode.getObject().isDeleted()) {
                enabled = false;
            }
        }
    }
    if (ProxyRepositoryFactory.getInstance().isUserReadOnlyOnCurrentProject()) {
        enabled = false;
    }
    if (enabled) {
        enabled = ProjectManager.getInstance().isInCurrentMainProject(repositoryNode);
    }
    setEnabled(enabled);
}
Also used : ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 3 with ERepositoryObjectType

use of org.talend.core.model.repository.ERepositoryObjectType in project tdi-studio-se by Talend.

the class AssignmentPropertySection method createRepositoryNode.

private RepositoryNode createRepositoryNode(BusinessAssignment businessAssignment) {
    IRepositoryViewObject lastVersion;
    try {
        lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(businessAssignment.getTalendItem().getId());
        if (lastVersion != null) {
            ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(lastVersion.getProperty().getItem());
            RepositoryNode repositoryNode = new RepositoryNode(lastVersion, RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(lastVersion), ENodeType.REPOSITORY_ELEMENT);
            repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
            return repositoryNode;
        }
    } catch (PersistenceException e) {
    }
    return null;
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 4 with ERepositoryObjectType

use of org.talend.core.model.repository.ERepositoryObjectType in project tdi-studio-se by Talend.

the class BusinessDiagramEditor method isLastVersion.

@Override
public boolean isLastVersion(Item item) {
    if (lastVersion != null) {
        return lastVersion;
    }
    if (item.getProperty() != null) {
        try {
            List<IRepositoryViewObject> allVersion = null;
            ItemState state = item.getState();
            ERepositoryObjectType type = ERepositoryObjectType.BUSINESS_PROCESS;
            if (type != null && state != null && state.getPath() != null) {
                allVersion = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getAllVersion(item.getProperty().getId(), state.getPath(), type);
            } else {
                allVersion = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getAllVersion(item.getProperty().getId());
            }
            if (allVersion == null || allVersion.isEmpty()) {
                return false;
            }
            String lastVersion = VersionUtils.DEFAULT_VERSION;
            for (IRepositoryViewObject object : allVersion) {
                if (VersionUtils.compareTo(object.getVersion(), lastVersion) > 0) {
                    lastVersion = object.getVersion();
                }
            }
            if (VersionUtils.compareTo(item.getProperty().getVersion(), lastVersion) == 0) {
                return true;
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
    return false;
}
Also used : ItemState(org.talend.core.model.properties.ItemState) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 5 with ERepositoryObjectType

use of org.talend.core.model.repository.ERepositoryObjectType in project tdi-studio-se by Talend.

the class JSONRepositoryContentHandler method hideAction.

@Override
public boolean hideAction(IRepositoryNode node, Class actionType) {
    boolean canHandle = false;
    ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
    if (JSONRepositoryNodeType.JSON.equals(nodeType)) {
        canHandle = true;
    }
    if (!canHandle) {
        if (ERepositoryObjectType.METADATA_CON_TABLE.equals(nodeType) || ERepositoryObjectType.METADATA_CON_COLUMN.equals(nodeType)) {
            RepositoryNode parentNode = node.getParent();
            if (parentNode != null && JSONRepositoryNodeType.JSON.equals(parentNode.getProperties(EProperties.CONTENT_TYPE))) {
                canHandle = true;
            }
        }
    }
    if (canHandle) {
        if (actionType == CreateTableAction.class) {
            return true;
        }
    }
    return false;
}
Also used : ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Aggregations

ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)128 RepositoryNode (org.talend.repository.model.RepositoryNode)44 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)43 ArrayList (java.util.ArrayList)24 PersistenceException (org.talend.commons.exception.PersistenceException)24 Item (org.talend.core.model.properties.Item)23 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)20 IRepositoryNode (org.talend.repository.model.IRepositoryNode)20 ProcessItem (org.talend.core.model.properties.ProcessItem)14 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)12 IPath (org.eclipse.core.runtime.IPath)11 ConnectionItem (org.talend.core.model.properties.ConnectionItem)11 Image (org.eclipse.swt.graphics.Image)10 RepositoryObject (org.talend.core.model.repository.RepositoryObject)9 List (java.util.List)8 Path (org.eclipse.core.runtime.Path)8 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)8 IElementParameter (org.talend.core.model.process.IElementParameter)8 Property (org.talend.core.model.properties.Property)8 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)8