Search in sources :

Example 1 with IExtendedRepositoryNodeHandler

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

the class ExportItemWizardPage method exportDependenciesSelected.

/**
     * DOC qwei Comment method "exportDependenciesSelected".
     */
private void exportDependenciesSelected() {
    final Collection<Item> selectedItems = getSelectedItems();
    // addTreeCheckedSelection();
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        @Override
        public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            //$NON-NLS-1$
            monitor.beginTask("Dependencies", 100);
            //
            final List<IRepositoryViewObject> repositoryObjects = new ArrayList<IRepositoryViewObject>();
            ProcessUtils.clearFakeProcesses();
            RepositoryNodeUtilities.checkItemDependencies(selectedItems, repositoryObjects, false, true);
            monitor.worked(60);
            for (IRepositoryViewObject repositoryObject : repositoryObjects) {
                RepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(repositoryObject, monitor);
                if (repositoryNode != null) {
                    checkedDependency.add(repositoryNode);
                } else {
                    implicitDependences.add(repositoryObject);
                }
                // check relateion ship for job -->map -->structure
                for (IExtendedRepositoryNodeHandler nodeHandler : RepositoryContentManager.getExtendedNodeHandler()) {
                    List nodesAndDependencies = nodeHandler.getRepositoryNodeAndDependencies(repositoryObject);
                    if (!nodesAndDependencies.isEmpty()) {
                        checkedDependency.addAll(nodesAndDependencies);
                    }
                }
            }
            // check relateion ship for map -->structure
            for (Item item : selectedItems) {
                for (IExtendedRepositoryNodeHandler nodeHandler : RepositoryContentManager.getExtendedNodeHandler()) {
                    List nodesAndDependencies = nodeHandler.getRepositoryNodeAndDependencies(new RepositoryObject(item.getProperty()));
                    if (!nodesAndDependencies.isEmpty()) {
                        checkedDependency.addAll(nodesAndDependencies);
                    }
                }
            }
            monitor.worked(90);
            ProcessUtils.clearFakeProcesses();
            monitor.done();
        }
    };
    // final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(getShell());
    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
    try {
        dialog.run(true, true, runnable);
    } catch (InvocationTargetException e) {
    //
    } catch (InterruptedException e) {
    //
    }
}
Also used : MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Item(org.talend.core.model.properties.Item) TreeItem(org.eclipse.swt.widgets.TreeItem) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IExtendedRepositoryNodeHandler(org.talend.core.model.repository.IExtendedRepositoryNodeHandler) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with IExtendedRepositoryNodeHandler

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

the class ExportItemWizardPage method collectNodes.

private void collectNodes(Map<String, Item> items, Object[] objects) {
    for (Object object : objects) {
        if (object instanceof RepositoryNode) {
            RepositoryNode repositoryNode = (RepositoryNode) object;
            IRepositoryViewObject repositoryObject = repositoryNode.getObject();
            if (repositoryObject != null) {
                if (repositoryObject.getRepositoryObjectType().isResourceItem()) {
                    Item item = repositoryObject.getProperty().getItem();
                    items.put(item.getProperty().getId(), item);
                }
            } else {
                if (repositoryNode.getParent() != null && repositoryNode.getParent().getObject() != null) {
                    Item item = repositoryNode.getParent().getObject().getProperty().getItem();
                    items.put(item.getProperty().getId(), item);
                }
            }
            if (filteredCheckboxTree != null && !isHadoopClusterNode(repositoryNode)) {
                IContentProvider contentProvider = filteredCheckboxTree.getViewer().getContentProvider();
                if (contentProvider instanceof ITreeContentProvider) {
                    // only check childrens of allowed items in this viewer
                    if (selectRepositoryNode(getItemsTreeViewer(), repositoryNode)) {
                        Object[] children = ((ITreeContentProvider) contentProvider).getChildren(repositoryNode);
                        List<Object> childrenNodes = getUnTestCaseChildren(children);
                        collectNodes(items, childrenNodes.toArray());
                    }
                }
            }
        } else {
            for (IExtendedRepositoryNodeHandler nodeHandler : RepositoryContentManager.getExtendedNodeHandler()) {
                Property property = nodeHandler.getProperty(object);
                if (property != null) {
                    items.put(property.getId(), property.getItem());
                }
            }
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) TreeItem(org.eclipse.swt.widgets.TreeItem) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) IExtendedRepositoryNodeHandler(org.talend.core.model.repository.IExtendedRepositoryNodeHandler) IContentProvider(org.eclipse.jface.viewers.IContentProvider) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Property(org.talend.core.model.properties.Property)

Example 3 with IExtendedRepositoryNodeHandler

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

the class ExportItemWizardPage method getObjectType.

private ERepositoryObjectType getObjectType(Object nodeObject) {
    ERepositoryObjectType objectType = null;
    if (nodeObject instanceof RepositoryNode) {
        RepositoryNode node = (RepositoryNode) nodeObject;
        objectType = node.getObjectType();
        // for user folders in metadata , routines , documentation
        if (ERepositoryObjectType.FOLDER.equals(objectType)) {
            RepositoryNode rootNode = getParentNodeNotFolder(node);
            objectType = rootNode.getContentType();
        }
        if (objectType == null) {
            objectType = node.getContentType();
        }
    } else {
        for (IExtendedRepositoryNodeHandler nodeHandler : RepositoryContentManager.getExtendedNodeHandler()) {
            objectType = nodeHandler.getObjectType(nodeObject);
            if (objectType != null) {
                return objectType;
            }
        }
    }
    return objectType;
}
Also used : IExtendedRepositoryNodeHandler(org.talend.core.model.repository.IExtendedRepositoryNodeHandler) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Aggregations

IExtendedRepositoryNodeHandler (org.talend.core.model.repository.IExtendedRepositoryNodeHandler)3 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)3 IRepositoryNode (org.talend.repository.model.IRepositoryNode)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 IProjectRepositoryNode (org.talend.repository.model.nodes.IProjectRepositoryNode)3 TreeItem (org.eclipse.swt.widgets.TreeItem)2 Item (org.talend.core.model.properties.Item)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 RepositoryObject (org.talend.core.model.repository.RepositoryObject)2 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 IContentProvider (org.eclipse.jface.viewers.IContentProvider)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 Property (org.talend.core.model.properties.Property)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1