Search in sources :

Example 71 with INodeConnector

use of org.talend.core.model.process.INodeConnector in project tesb-studio-se by Talend.

the class CamelDesignerCoreService method getTargetConnectionType.

@Override
public EConnectionType getTargetConnectionType(INode node) {
    INodeConnector connector = node.getConnectorFromType(EConnectionType.ROUTE);
    if (connector.getMaxLinkOutput() > 0) {
        return EConnectionType.ROUTE;
    }
    connector = node.getConnectorFromType(EConnectionType.ROUTE_ENDBLOCK);
    if (connector.getMaxLinkOutput() > 0) {
        return EConnectionType.ROUTE_ENDBLOCK;
    }
    return EConnectionType.ROUTE;
}
Also used : INodeConnector(org.talend.core.model.process.INodeConnector)

Example 72 with INodeConnector

use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.

the class SimpleOutputComponent method createConnectors.

@Override
public List<? extends INodeConnector> createConnectors(INode node) {
    List<NodeConnector> nodeConnectors = new ArrayList<NodeConnector>();
    NodeConnector connector = createBaseConnector(node, EConnectionType.FLOW_MAIN);
    connector.setMaxLinkInput(1);
    connector.setMaxLinkOutput(1);
    nodeConnectors.add(connector);
    return nodeConnectors;
}
Also used : NodeConnector(org.talend.designer.core.model.components.NodeConnector) INodeConnector(org.talend.core.model.process.INodeConnector) ArrayList(java.util.ArrayList)

Example 73 with INodeConnector

use of org.talend.core.model.process.INodeConnector 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)

Example 74 with INodeConnector

use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.

the class ConnectionCreateCommandTest method redoSimpleInputToSimpleOutput3.

/**
     * DOC nrousseau Comment method "redoSimpleInputToSimpleOutput1".
     */
private void redoSimpleInputToSimpleOutput3() {
    ConnectionCreateCommand ccc = undoSimpleInputToSimpleOutput3();
    ccc.redo();
    //$NON-NLS-1$
    INodeConnector inputConnector = ccc.source.getConnectorFromName("FLOW");
    //$NON-NLS-1$
    INodeConnector outputConnector = ccc.target.getConnectorFromName("FLOW");
    assertEquals(inputConnector.getCurLinkNbOutput(), 1);
    assertEquals(outputConnector.getCurLinkNbInput(), 1);
}
Also used : INodeConnector(org.talend.core.model.process.INodeConnector)

Example 75 with INodeConnector

use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.

the class ConnectionCreateCommandTest method executeSimpleInputToSimpleOutput2.

/**
     * simple input to simple output with metadata already existing and schema auto propagate.
     */
private ConnectionCreateCommand executeSimpleInputToSimpleOutput2() {
    IProcess2 process = getFakeProcess();
    Node simpleInputNode = NodeTestCreator.createSimpleInputNode(process);
    // simple tests only since it's simply using the class ConnectionManager which already have JUnits.
    List<Object> args = new ArrayList<Object>();
    args.add(simpleInputNode.getUniqueName());
    //$NON-NLS-1$
    args.add("connectionName");
    simpleInputNode.getMetadataList().clear();
    IMetadataTable table1 = createSimpleMetadata1();
    table1.setTableName(simpleInputNode.getUniqueName());
    table1.setLabel(simpleInputNode.getUniqueName());
    //$NON-NLS-1$
    table1.setAttachedConnector("FLOW");
    simpleInputNode.getMetadataList().add(table1);
    // set null, the command should take the schema from the component directly
    args.add(null);
    //$NON-NLS-1$
    ConnectionCreateCommand ccc = new ConnectionCreateCommand(simpleInputNode, "FLOW", args);
    ConnectionCreateCommand.setCreatingConnection(true);
    Node simpleOutputNode = NodeTestCreator.createSimpleOutputNode(process);
    simpleOutputNode.getMetadataList().clear();
    IMetadataTable table2 = createSimpleMetadata2();
    table2.setTableName(simpleOutputNode.getUniqueName());
    table2.setLabel(simpleOutputNode.getUniqueName());
    //$NON-NLS-1$
    table2.setAttachedConnector("FLOW");
    simpleOutputNode.getMetadataList().add(table2);
    ccc.setTarget(simpleOutputNode);
    ccc.execute();
    assertEquals(simpleInputNode.getOutgoingConnections().size(), 1);
    assertEquals(simpleOutputNode.getIncomingConnections().size(), 1);
    assertEquals(simpleOutputNode.getMetadataList().size(), 1);
    IMetadataTable outputMetadata = simpleOutputNode.getMetadataList().get(0);
    // metadata should have been propagated automatically
    assertMetadataIsSame(table1, outputMetadata);
    IConnection connection = simpleInputNode.getOutgoingConnections().get(0);
    assertEquals(simpleOutputNode.getIncomingConnections().get(0), connection);
    assertEquals(connection.getSource(), simpleInputNode);
    assertEquals(connection.getTarget(), simpleOutputNode);
    assertEquals(connection.getMetaName(), simpleInputNode.getUniqueName());
    //$NON-NLS-1$
    assertEquals(connection.getConnectorName(), "FLOW");
    //$NON-NLS-1$
    INodeConnector inputConnector = simpleInputNode.getConnectorFromName("FLOW");
    //$NON-NLS-1$
    INodeConnector outputConnector = simpleOutputNode.getConnectorFromName("FLOW");
    assertEquals(inputConnector.getCurLinkNbOutput(), 1);
    assertEquals(outputConnector.getCurLinkNbInput(), 1);
    return ccc;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Node(org.talend.designer.core.ui.editor.nodes.Node) IProcess2(org.talend.core.model.process.IProcess2) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) INodeConnector(org.talend.core.model.process.INodeConnector)

Aggregations

INodeConnector (org.talend.core.model.process.INodeConnector)76 ArrayList (java.util.ArrayList)37 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)31 INode (org.talend.core.model.process.INode)31 Node (org.talend.designer.core.ui.editor.nodes.Node)31 IConnection (org.talend.core.model.process.IConnection)27 IElementParameter (org.talend.core.model.process.IElementParameter)22 Process (org.talend.designer.core.ui.editor.process.Process)21 List (java.util.List)20 Connection (org.talend.designer.core.ui.editor.connections.Connection)17 IJobletProviderService (org.talend.core.ui.IJobletProviderService)14 HashMap (java.util.HashMap)11 NodeConnector (org.talend.designer.core.model.components.NodeConnector)11 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)9 EConnectionType (org.talend.core.model.process.EConnectionType)9 Map (java.util.Map)8 IExternalNode (org.talend.core.model.process.IExternalNode)7 IProcess (org.talend.core.model.process.IProcess)7 RepositoryNode (org.talend.repository.model.RepositoryNode)7 Point (org.eclipse.draw2d.geometry.Point)6