Search in sources :

Example 26 with IJobletProviderService

use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.

the class GEFDeleteAction method createDeleteCommand.

@Override
public Command createDeleteCommand(List objects) {
    objects = filterSameObject(objectsToDelete);
    if (objects.isEmpty()) {
        return null;
    }
    if (!(objects.get(0) instanceof EditPart)) {
        return null;
    }
    EditPart object = (EditPart) objects.get(0);
    // for TUP-1015
    boolean isConnAttachedJLTriggerComp = false;
    ConnectionPart connectionPart = null;
    if (object instanceof ConnectionPart) {
        connectionPart = (ConnectionPart) object;
    } else if (object instanceof ConnLabelEditPart) {
        connectionPart = (ConnectionPart) object.getParent();
    }
    if (connectionPart != null) {
        Node srcNode = null;
        Object srcModel = connectionPart.getSource().getModel();
        if (srcModel instanceof Node) {
            srcNode = (Node) srcModel;
        }
        Node tarNode = null;
        Object tarModel = connectionPart.getTarget().getModel();
        if (tarModel instanceof Node) {
            tarNode = (Node) tarModel;
        }
        if (srcNode == null || tarNode == null) {
            return null;
        }
        IProcess process = srcNode.getProcess();
        if (AbstractProcessProvider.isExtensionProcessForJoblet(process)) {
            IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
            if (service != null && (service.isTriggerNode(srcNode) || service.isTriggerNode(tarNode))) {
                isConnAttachedJLTriggerComp = true;
            }
        }
    }
    IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
    String preKey = TalendDesignerPrefConstants.NOT_SHOW_WARNING_WHEN_DELETE_LINK_WITH_JOBLETTRIGGERLINKCOMPONENT;
    if (isConnAttachedJLTriggerComp && !preferenceStore.getBoolean(preKey)) {
        MessageDialogWithToggle jlTriggerConfirmDialog = new MessageDialogWithToggle(null, //$NON-NLS-1$
        Messages.getString("GEFDeleteAction.deleteConnectionDialog.title"), // accept the default window icon
        null, Messages.getString("GEFDeleteAction.deleteConnectionDialog.msg"), MessageDialog.WARNING, new String[] { //$NON-NLS-1$
        IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, //$NON-NLS-1$
        Messages.getString("GEFDeleteAction.deleteConnectionDialog.toggleMsg"), preferenceStore.getDefaultBoolean(preKey));
        jlTriggerConfirmDialog.setPrefStore(preferenceStore);
        jlTriggerConfirmDialog.setPrefKey(preKey);
        if (jlTriggerConfirmDialog.open() != IDialogConstants.YES_ID) {
            return null;
        }
        preferenceStore.setValue(preKey, jlTriggerConfirmDialog.getToggleState());
    }
    List nodeParts = new ArrayList();
    List noteParts = new ArrayList();
    List others = new ArrayList(objects);
    for (Object o : objects) {
        if (o instanceof NodePart) {
            others.remove(o);
            Node model = (Node) ((NodePart) o).getModel();
            if (model.getJobletNode() != null) {
                continue;
            }
            if (model.getJunitNode() != null) {
                continue;
            }
            nodeParts.add(o);
        } else if (o instanceof NoteEditPart) {
            noteParts.add(o);
            others.remove(o);
        } else if (o instanceof SubjobContainerPart) {
            others.remove(o);
            SubjobContainerPart subjob = (SubjobContainerPart) o;
            for (Iterator iterator = subjob.getChildren().iterator(); iterator.hasNext(); ) {
                NodeContainerPart nodeContainerPart = (NodeContainerPart) iterator.next();
                if (nodeContainerPart instanceof JobletContainerPart) {
                    JobletContainer jobletCon = (JobletContainer) ((JobletContainerPart) nodeContainerPart).getModel();
                    JobletContainerFigure jobletFigure = (JobletContainerFigure) ((JobletContainerPart) nodeContainerPart).getFigure();
                    if (!jobletCon.isCollapsed()) {
                        jobletFigure.doCollapse();
                    }
                }
                NodePart nodePart = nodeContainerPart.getNodePart();
                if (nodePart != null) {
                    Node model = (Node) nodePart.getModel();
                    if (model.getJunitNode() != null) {
                        continue;
                    }
                    nodeParts.add(nodePart);
                }
            }
        }
    }
    if (others.size() == 0) {
        // so notes & nodes only
        CompoundCommand cpdCmd = new CompoundCommand();
        //$NON-NLS-1$
        cpdCmd.setLabel(Messages.getString("GEFDeleteAction.DeleteItems"));
        if (nodeParts.size() != 0) {
            GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
            deleteReq.setEditParts(nodeParts);
            cpdCmd.add(((NodePart) nodeParts.get(0)).getCommand(deleteReq));
        }
        if (noteParts.size() != 0) {
            GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
            deleteReq.setEditParts(noteParts);
            cpdCmd.add(((NoteEditPart) noteParts.get(0)).getCommand(deleteReq));
        }
        return cpdCmd;
    } else {
        GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
        deleteReq.setEditParts(objects);
        Command cmd = object.getCommand(deleteReq);
        return cmd;
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) JobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainer) Node(org.talend.designer.core.ui.editor.nodes.Node) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) EditPart(org.eclipse.gef.EditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) ArrayList(java.util.ArrayList) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) JobletContainerPart(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) IJobletProviderService(org.talend.core.ui.IJobletProviderService) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) Iterator(java.util.Iterator) JobletContainerFigure(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerFigure) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) ArrayList(java.util.ArrayList) List(java.util.List) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) IProcess(org.talend.core.model.process.IProcess)

Example 27 with IJobletProviderService

use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.

the class ConnectionCreateAction method getConnectors.

public List<INodeConnector> getConnectors() {
    List<INodeConnector> list = new ArrayList<INodeConnector>();
    if (getSelectedObjects().isEmpty()) {
        return list;
    }
    List parts = getSelectedObjects();
    if (parts.size() == 1) {
        Object o = parts.get(0);
        if (!(o instanceof NodePart)) {
            return list;
        }
        nodePart = (NodePart) o;
        if (!(nodePart.getModel() instanceof Node)) {
            return list;
        }
        Node node = (Node) nodePart.getModel();
        if (!node.isActivate()) {
            return list;
        }
        List<INodeConnector> nodeConnectorList = new ArrayList<INodeConnector>(node.getConnectorsFromType(connecType));
        List<INodeConnector> toRemove = new ArrayList<INodeConnector>();
        for (INodeConnector connector : nodeConnectorList) {
            if ((connector.getMaxLinkOutput() != -1) && (connector.getCurLinkNbOutput() >= connector.getMaxLinkOutput())) {
                toRemove.add(connector);
            } else {
                if (PluginChecker.isJobLetPluginLoaded()) {
                    IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                    if (service != null) {
                        if (service.isJobletComponent(node) && !service.isBuiltTriggerConnector(node, connector)) {
                            toRemove.add(connector);
                        }
                        // for bug 10973
                        List<? extends IConnection> outgoingConnections = node.getOutgoingConnections();
                        if (service.isTriggerInputNode(node) && outgoingConnections != null && outgoingConnections.size() >= 1) {
                            toRemove.add(connector);
                        }
                    }
                }
            }
        }
        nodeConnectorList.removeAll(toRemove);
        return nodeConnectorList;
    }
    return list;
}
Also used : IJobletProviderService(org.talend.core.ui.IJobletProviderService) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 28 with IJobletProviderService

use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.

the class ComponentChooseDialog method createComponentOnLink.

private boolean createComponentOnLink(Node node, Point originalPoint) {
    boolean executed = false;
    RootEditPart rep = editor.getViewer().getRootEditPart().getRoot();
    Point viewOriginalPosition = new Point();
    if (rep instanceof ScalableFreeformRootEditPart) {
        ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep;
        Viewport viewport = (Viewport) root.getFigure();
        viewOriginalPosition = viewport.getViewLocation();
    }
    Point point = new Point(originalPoint.x + viewOriginalPosition.x, originalPoint.y + viewOriginalPosition.y);
    point.x = (int) (point.x / AnimatableZoomManager.currentZoom);
    point.y = (int) (point.y / AnimatableZoomManager.currentZoom);
    org.talend.designer.core.ui.editor.connections.Connection targetConnection = null;
    if (selectedConnectionPart != null) {
        targetConnection = (org.talend.designer.core.ui.editor.connections.Connection) selectedConnectionPart.getModel();
    }
    if (targetConnection != null) {
        IProcess2 p = editor.getProcess();
        NodeContainer nodeContainer = ((Process) node.getProcess()).loadNodeContainer(node, false);
        // TDI-21099
        if (p instanceof Process) {
            CreateNodeContainerCommand createCmd = new CreateNodeContainerCommand((Process) p, nodeContainer, point);
            execCommandStack(createCmd);
            // reconnect the node
            Node originalTarget = (Node) targetConnection.getTarget();
            EConnectionType connectionType = EConnectionType.FLOW_MAIN;
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
                ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
                if (camelService.isRouteBuilderNode(node)) {
                    connectionType = camelService.getTargetConnectionType(node);
                }
            }
            INodeConnector targetConnector = node.getConnectorFromType(connectionType);
            for (INodeConnector connector : node.getConnectorsFromType(connectionType)) {
                if (connector.getMaxLinkOutput() != 0) {
                    targetConnector = connector;
                    break;
                }
            }
            ConnectionCreateCommand.setCreatingConnection(true);
            // bug 21411
            if (PluginChecker.isJobLetPluginLoaded()) {
                IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                if (service != null && service.isJobletComponent(targetConnection.getTarget())) {
                    if (targetConnection.getTarget() instanceof Node) {
                        NodeContainer jobletContainer = ((Node) targetConnection.getTarget()).getNodeContainer();
                        // remove the old connection in the container
                        jobletContainer.getInputs().remove(targetConnection);
                    }
                }
            }
            ConnectionReconnectCommand cmd2 = new ConnectionReconnectCommand(targetConnection);
            cmd2.setNewTarget(node);
            execCommandStack(cmd2);
            List<Object> nodeArgs = CreateComponentOnLinkHelper.getTargetArgs(targetConnection, node);
            ConnectionCreateCommand nodeCmd = new ConnectionCreateCommand(node, targetConnector.getName(), nodeArgs, false);
            nodeCmd.setTarget(originalTarget);
            execCommandStack(nodeCmd);
            // Setting,such as the target is TMap
            if (node.getOutgoingConnections().size() > 0) {
                if (node.getExternalNode() instanceof MapperExternalNode) {
                    CreateComponentOnLinkHelper.setupTMap(node);
                }
                if (originalTarget.getExternalNode() instanceof MapperExternalNode) {
                    CreateComponentOnLinkHelper.updateTMap(originalTarget, targetConnection, node.getOutgoingConnections().get(0));
                }
                originalTarget.renameData(targetConnection.getName(), node.getOutgoingConnections().get(0).getName());
            }
            if (!ConnectionCreateCommand.isCreatingConnection()) {
                return true;
            }
            executed = true;
        }
    }
    return executed;
}
Also used : ICamelDesignerCoreService(org.talend.designer.core.ICamelDesignerCoreService) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) Viewport(org.eclipse.draw2d.Viewport) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IProcess(org.talend.core.model.process.IProcess) Point(org.eclipse.draw2d.geometry.Point) INodeConnector(org.talend.core.model.process.INodeConnector) ConnectionReconnectCommand(org.talend.designer.core.ui.editor.cmd.ConnectionReconnectCommand) IJobletProviderService(org.talend.core.ui.IJobletProviderService) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) IProcess2(org.talend.core.model.process.IProcess2) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) EConnectionType(org.talend.core.model.process.EConnectionType) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart)

Example 29 with IJobletProviderService

use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.

the class ImportItemUtil method importItemRecords.

@SuppressWarnings("unchecked")
public List<ItemRecord> importItemRecords(final ResourcesManager manager, final List<ItemRecord> itemRecords, final IProgressMonitor monitor, final boolean overwrite, final IPath destinationPath, final String contentType) {
    TimeMeasure.display = CommonsPlugin.isDebugMode();
    TimeMeasure.displaySteps = CommonsPlugin.isDebugMode();
    TimeMeasure.measureActive = CommonsPlugin.isDebugMode();
    TimeMeasure.begin("importItemRecords");
    hasJoblets = false;
    statAndLogsSettingsReloaded = false;
    implicitSettingsReloaded = false;
    restoreFolder = new RestoreFolderUtil();
    Collections.sort(itemRecords, new Comparator<ItemRecord>() {

        @Override
        public int compare(ItemRecord o1, ItemRecord o2) {
            if (o1.getProperty().getItem() instanceof RoutineItem && o2.getProperty().getItem() instanceof RoutineItem) {
                return 0;
            } else if (!(o1.getProperty().getItem() instanceof RoutineItem) && !(o2.getProperty().getItem() instanceof RoutineItem)) {
                // TUP-2548 sort items by label
                String label = o1.getLabel();
                if (label == null) {
                    return -1;
                }
                final String label2 = o2.getLabel();
                if (label2 == null) {
                    return 1;
                }
                return label.compareTo(label2);
            } else if (o1.getProperty().getItem() instanceof RoutineItem) {
                return -1;
            } else {
                return 1;
            }
        }
    });
    //$NON-NLS-1$
    monitor.beginTask(Messages.getString("ImportItemWizardPage.ImportSelectedItems"), itemRecords.size() * 2 + 1);
    RepositoryWorkUnit repositoryWorkUnit = new //$NON-NLS-1$
    RepositoryWorkUnit(//$NON-NLS-1$
    "Import Items") {

        @Override
        public void run() throws PersistenceException {
            final IWorkspaceRunnable op = new IWorkspaceRunnable() {

                @Override
                public void run(IProgressMonitor monitor) throws CoreException {
                    final IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
                    // bug 10520
                    final Set<String> overwriteDeletedItems = new HashSet<String>();
                    final Set<String> idDeletedBeforeImport = new HashSet<String>();
                    Map<String, String> nameToIdMap = new HashMap<String, String>();
                    for (ItemRecord itemRecord : itemRecords) {
                        if (!monitor.isCanceled()) {
                            if (itemRecord.isValid()) {
                                if (itemRecord.getState() == State.ID_EXISTED) {
                                    String id = nameToIdMap.get(itemRecord.getProperty().getLabel() + ERepositoryObjectType.getItemType(itemRecord.getProperty().getItem()).toString());
                                    if (id == null) {
                                        /*
                                             * if id exsist then need to genrate new id for this job,in this case the
                                             * job won't override the old one
                                             */
                                        id = EcoreUtil.generateUUID();
                                        nameToIdMap.put(itemRecord.getProperty().getLabel() + ERepositoryObjectType.getItemType(itemRecord.getProperty().getItem()).toString(), id);
                                    }
                                    itemRecord.getProperty().setId(id);
                                }
                            }
                        }
                    }
                    for (ItemRecord itemRecord : itemRecords) {
                        if (!monitor.isCanceled()) {
                            if (itemRecord.isValid()) {
                                importItemRecord(manager, itemRecord, overwrite, destinationPath, overwriteDeletedItems, idDeletedBeforeImport, contentType, monitor);
                                IRepositoryViewObject object;
                                try {
                                    Property property = itemRecord.getProperty();
                                    if (property == null) {
                                        object = factory.getSpecificVersion(itemRecord.getItemId(), itemRecord.getItemVersion(), true);
                                        property = object.getProperty();
                                    }
                                    RelationshipItemBuilder.getInstance().addOrUpdateItem(property.getItem(), true);
                                    itemRecord.setProperty(null);
                                    ProxyRepositoryFactory.getInstance().unloadResources(property);
                                } catch (PersistenceException e) {
                                    ExceptionHandler.process(e);
                                }
                                statAndLogsSettingsReloaded = false;
                                implicitSettingsReloaded = false;
                                monitor.worked(1);
                            }
                        }
                    }
                    // deploy routines Jar
                    if (!getRoutineExtModulesMap().isEmpty()) {
                        Set<String> extRoutines = new HashSet<String>();
                        for (String id : getRoutineExtModulesMap().keySet()) {
                            Set<String> set = getRoutineExtModulesMap().get(id);
                            if (set != null) {
                                extRoutines.addAll(set);
                            }
                        }
                        if (manager instanceof ProviderManager || manager instanceof ZipFileManager) {
                            deployJarToDesForArchive(manager, extRoutines);
                        } else {
                            deployJarToDes(manager, extRoutines);
                        }
                    }
                    if (PluginChecker.isJobLetPluginLoaded()) {
                        IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                        if (service != null) {
                            service.loadComponentsFromProviders();
                        }
                    }
                    checkDeletedFolders();
                    monitor.done();
                    TimeMeasure.step("importItemRecords", "before save");
                    if (RelationshipItemBuilder.getInstance().isNeedSaveRelations()) {
                        RelationshipItemBuilder.getInstance().saveRelations();
                        TimeMeasure.step("importItemRecords", "save relations");
                    } else {
                        // with relations
                        try {
                            factory.saveProject(ProjectManager.getInstance().getCurrentProject());
                        } catch (PersistenceException e) {
                            throw new CoreException(new Status(IStatus.ERROR, FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "Import errors", e));
                        }
                        TimeMeasure.step("importItemRecords", "save project");
                    }
                }
            };
            IWorkspace workspace = ResourcesPlugin.getWorkspace();
            try {
                ISchedulingRule schedulingRule = workspace.getRoot();
                // the update the project files need to be done in the workspace runnable to avoid all
                // notification
                // of changes before the end of the modifications.
                workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
            } catch (CoreException e) {
            // ?
            }
        }
    };
    repositoryWorkUnit.setAvoidUnloadResources(true);
    repositoryWorkUnit.setUnloadResourcesAfterRun(true);
    ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(repositoryWorkUnit);
    monitor.done();
    // for (ItemRecord itemRecord : itemRecords) {
    // itemRecord.clear();
    // }
    clearAllData();
    if (hasJoblets) {
        ComponentsFactoryProvider.getInstance().resetSpecificComponents();
    }
    TimeMeasure.end("importItemRecords");
    TimeMeasure.display = false;
    TimeMeasure.displaySteps = false;
    TimeMeasure.measureActive = false;
    return itemRecords;
}
Also used : Status(org.eclipse.core.runtime.Status) ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IStatus(org.eclipse.core.runtime.IStatus) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) HashMap(java.util.HashMap) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) RoutineItem(org.talend.core.model.properties.RoutineItem) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) IJobletProviderService(org.talend.core.ui.IJobletProviderService) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) RestoreFolderUtil(org.talend.core.repository.ui.actions.RestoreFolderUtil) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) HashSet(java.util.HashSet)

Example 30 with IJobletProviderService

use of org.talend.core.ui.IJobletProviderService in project tdi-studio-se by Talend.

the class ConnectionCreateActionTest method testGetConnectors.

/**
     * Test method for {@link org.talend.designer.core.ui.action.ConnectionCreateAction#getConnectors()}.
     */
@Test
public void testGetConnectors() {
    List<INodeConnector> list = new ArrayList<INodeConnector>();
    List<INodeConnector> nodeConnectorList = new ArrayList<INodeConnector>(node.getConnectorsFromType(EConnectionType.FLOW_MAIN));
    int connecSize = nodeConnectorList.size();
    List<INodeConnector> toRemove = new ArrayList<INodeConnector>();
    for (INodeConnector connector : nodeConnectorList) {
        if ((connector.getMaxLinkOutput() != -1) && (connector.getCurLinkNbOutput() >= connector.getMaxLinkOutput())) {
            toRemove.add(connector);
        } else {
            if (PluginChecker.isJobLetPluginLoaded()) {
                IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                if (service != null) {
                    if (service.isJobletComponent(node) && !service.isBuiltTriggerConnector(node, connector)) {
                        toRemove.add(connector);
                    }
                    List<? extends IConnection> outgoingConnections = node.getOutgoingConnections();
                    if (service.isTriggerInputNode(node) && outgoingConnections != null && outgoingConnections.size() >= 1) {
                        toRemove.add(connector);
                    }
                }
            }
        }
    }
    nodeConnectorList.removeAll(toRemove);
    assertEquals(nodeConnectorList.size(), connecSize - toRemove.size());
}
Also used : IJobletProviderService(org.talend.core.ui.IJobletProviderService) ArrayList(java.util.ArrayList) INodeConnector(org.talend.core.model.process.INodeConnector) Test(org.junit.Test)

Aggregations

IJobletProviderService (org.talend.core.ui.IJobletProviderService)30 INode (org.talend.core.model.process.INode)17 Node (org.talend.designer.core.ui.editor.nodes.Node)17 ArrayList (java.util.ArrayList)14 INodeConnector (org.talend.core.model.process.INodeConnector)14 IConnection (org.talend.core.model.process.IConnection)13 List (java.util.List)12 IElementParameter (org.talend.core.model.process.IElementParameter)10 IProcess (org.talend.core.model.process.IProcess)8 Connection (org.talend.designer.core.ui.editor.connections.Connection)8 HashMap (java.util.HashMap)7 IExternalNode (org.talend.core.model.process.IExternalNode)7 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)7 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)6 Point (org.eclipse.draw2d.geometry.Point)5 IProcess2 (org.talend.core.model.process.IProcess2)5 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)5 HashSet (java.util.HashSet)4 PersistenceException (org.talend.commons.exception.PersistenceException)4 Map (java.util.Map)3