Search in sources :

Example 11 with IConnection

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

the class ProblemsAnalyser method checkProblems.

public List<Problem> checkProblems(ExternalDbMapData externalData) {
    problems.clear();
    if (externalData != null) {
        List<IConnection> incomingConnections = new ArrayList<IConnection>(this.mapperManager.getComponent().getIncomingConnections());
        List<IConnection> outgoingConnections = new ArrayList<IConnection>(this.mapperManager.getComponent().getOutgoingConnections());
        ExternalDataConverter converter = new ExternalDataConverter(mapperManager);
        MapperMain mapperMain = mapperManager.getComponent().getMapperMain();
        List<IOConnection> inputsIOConnections = mapperMain.createIOConnections(incomingConnections);
        ArrayList<InputTable> inputTables = converter.prepareInputTables(inputsIOConnections, externalData);
        List<IOConnection> outputsIOConnections = mapperMain.createIOConnections(outgoingConnections);
        ArrayList<OutputTable> outputTables = converter.prepareOutputTables(outputsIOConnections, this.mapperManager.getComponent().getMetadataList(), externalData);
        List<? super AbstractInOutTable> tablesWriteMode = new ArrayList<AbstractInOutTable>();
        tablesWriteMode.addAll(inputTables);
        tablesWriteMode.addAll(outputTables);
        List<? extends AbstractInOutTable> tablesReadMode = (List<? extends AbstractInOutTable>) tablesWriteMode;
        ProblemsManager problemsManager = new ProblemsManager(mapperManager);
        ArrayList<Problem> problemsLocal = new ArrayList<Problem>();
        for (AbstractInOutTable table : tablesReadMode) {
            List<IColumnEntry> columnEntries = table.getColumnEntries();
            problemsManager.checkProblemsForAllEntries(columnEntries);
            for (IColumnEntry entry : columnEntries) {
                List<Problem> problemsOfEntry = entry.getProblems();
                if (problemsOfEntry != null) {
                    problemsLocal.addAll(problemsOfEntry);
                }
            }
        }
        problems.addAll(problemsLocal);
    }
    return getProblems();
}
Also used : ExternalDataConverter(org.talend.designer.dbmap.external.converter.ExternalDataConverter) ArrayList(java.util.ArrayList) AbstractInOutTable(org.talend.designer.dbmap.model.table.AbstractInOutTable) IConnection(org.talend.core.model.process.IConnection) IColumnEntry(org.talend.designer.abstractmap.model.tableentry.IColumnEntry) OutputTable(org.talend.designer.dbmap.model.table.OutputTable) InputTable(org.talend.designer.dbmap.model.table.InputTable) IOConnection(org.talend.designer.dbmap.external.connection.IOConnection) ArrayList(java.util.ArrayList) List(java.util.List) Problem(org.talend.core.model.process.Problem) MapperMain(org.talend.designer.dbmap.MapperMain) ProblemsManager(org.talend.designer.dbmap.managers.ProblemsManager)

Example 12 with IConnection

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

the class ClearTraceAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    //
    final TraceConnectionsManager traceConnectionsManager = new TraceConnectionsManager(process);
    traceConnectionsManager.init();
    Set<IConnection> doneConnections = new HashSet<IConnection>();
    IConnection connection = null;
    for (Iterator<? extends INode> i = process.getGraphicalNodes().iterator(); connection == null && i.hasNext(); ) {
        INode psNode = i.next();
        if (psNode instanceof Node) {
            Node node = (Node) psNode;
            //$NON-NLS-1$
            node.getNodeProgressBar().updateState("UPDATE_STATUS", new Double(0));
            node.setErrorFlag(false);
            node.setCompareFlag(false);
            node.setErrorInfo(null);
            //$NON-NLS-1$
            node.getNodeError().updateState("UPDATE_STATUS", false);
            //$NON-NLS-1$
            node.setErrorInfoChange("ERRORINFO", false);
        }
        for (IConnection connec : psNode.getOutgoingConnections()) {
            if (!doneConnections.contains(connec)) {
                connec.setTraceData(null);
                doneConnections.add(connec);
            }
            // get the related shadow connections
            IConnection[] shadowconns = traceConnectionsManager.getShadowConnenctions(connec.getUniqueName());
            if (shadowconns != null) {
                for (IConnection sc : shadowconns) {
                    if (!doneConnections.contains(sc)) {
                        sc.setTraceData(null);
                        doneConnections.add(sc);
                    }
                }
            }
        }
        // currently, only for joblet when expanded.
        IConnection[] nonShadowDataConnections = traceConnectionsManager.getNonShadowDataConnections(psNode);
        if (nonShadowDataConnections != null) {
            for (IConnection conn : nonShadowDataConnections) {
                if (!doneConnections.contains(conn)) {
                    conn.setTraceData(null);
                    doneConnections.add(conn);
                }
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) IConnection(org.talend.core.model.process.IConnection) TraceConnectionsManager(org.talend.designer.runprocess.trace.TraceConnectionsManager) HashSet(java.util.HashSet)

Example 13 with IConnection

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

the class ConnectionCreateCommandTest method executeSimpleInputToSimpleOutput1.

/**
     * simple input to simple output with no metadata and schema auto propagate.
     */
private ConnectionCreateCommand executeSimpleInputToSimpleOutput1() {
    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 table = createSimpleMetadata1();
    table.setTableName(simpleInputNode.getUniqueName());
    table.setLabel(simpleInputNode.getUniqueName());
    //$NON-NLS-1$
    table.setAttachedConnector("FLOW");
    simpleInputNode.getMetadataList().add(table);
    // 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);
    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(table, 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)

Example 14 with IConnection

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

the class ChangeOutputConnectionOrderCommandTest method test.

@Test
public void test() {
    tSAPBapiComponent = ComponentsFactoryProvider.getInstance().get("tSAPBapi", ComponentCategory.CATEGORY_4_DI.getName());
    tLogRowComponent = ComponentsFactoryProvider.getInstance().get("tLogRow", ComponentCategory.CATEGORY_4_DI.getName());
    Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    //$NON-NLS-1$
    property1.setId("property1");
    //$NON-NLS-1$
    property1.setVersion("0.1");
    //$NON-NLS-1$
    property1.setLabel("test1");
    Process process = new Process(property1);
    Node tSAPBapi_1 = new Node(tSAPBapiComponent, process);
    tSAPBapi_1.getMetadataList().add(createMetadataTable("row_IV_KOKRS_1"));
    tSAPBapi_1.getMetadataList().add(createMetadataTable("row_ES_RETURN_1"));
    tSAPBapi_1.getMetadataList().add(createMetadataTable("row_ET_COSTELEMGRP_HIER_1"));
    tSAPBapi_1.getMetadataList().add(createMetadataTable("row_SINGLE_PARAM_1"));
    Node tLogRow_1 = new Node(tLogRowComponent, process);
    Connection conn1 = new Connection(tSAPBapi_1, tLogRow_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tSAPBapi_1", "row_ES_RETURN_1", "row_ES_RETURN_1", false);
    Connection conn2 = new Connection(tSAPBapi_1, tLogRow_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tSAPBapi_1", "row_ET_COSTELEMGRP_HIER_1", "row_ET_COSTELEMGRP_HIER_1", false);
    Connection conn3 = new Connection(tSAPBapi_1, tLogRow_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tSAPBapi_1", "row_SINGLE_PARAM_1", "row_SINGLE_PARAM_1", false);
    List<IConnection> reoderConnection = new ArrayList<IConnection>();
    reoderConnection.add(conn2);
    reoderConnection.add(conn3);
    reoderConnection.add(conn1);
    ChangeOutputConnectionOrderCommand command = new ChangeOutputConnectionOrderCommand(tSAPBapi_1, reoderConnection);
    command.execute();
    Assert.assertEquals(conn1.getConnectionLabel().getLabelText(), "row_ES_RETURN_1 (Main order:3)");
    Assert.assertEquals(conn2.getConnectionLabel().getLabelText(), "row_ET_COSTELEMGRP_HIER_1 (Main order:1)");
    Assert.assertEquals(conn3.getConnectionLabel().getLabelText(), "row_SINGLE_PARAM_1 (Main order:2)");
    command.undo();
    Assert.assertEquals(conn1.getConnectionLabel().getLabelText(), "row_ES_RETURN_1 (Main order:1)");
    Assert.assertEquals(conn2.getConnectionLabel().getLabelText(), "row_ET_COSTELEMGRP_HIER_1 (Main order:2)");
    Assert.assertEquals(conn3.getConnectionLabel().getLabelText(), "row_SINGLE_PARAM_1 (Main order:3)");
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) Process(org.talend.designer.core.ui.editor.process.Process) IConnection(org.talend.core.model.process.IConnection) Property(org.talend.core.model.properties.Property) Test(org.junit.Test)

Example 15 with IConnection

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

the class ConnectionCreateCommandTest method executeSimpleInputToSimpleOutput3.

/**
     * simple input to simple output with no metadata and without schema auto propagate.
     */
private ConnectionCreateCommand executeSimpleInputToSimpleOutput3() {
    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 table = createSimpleMetadata1();
    table.setTableName(simpleInputNode.getUniqueName());
    table.setLabel(simpleInputNode.getUniqueName());
    //$NON-NLS-1$
    table.setAttachedConnector("FLOW");
    simpleInputNode.getMetadataList().add(table);
    // 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.createSimpleOutputNodeNoPropagate(process);
    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);
    // no propagation
    assertEquals(outputMetadata.getListColumns().size(), 0);
    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

IConnection (org.talend.core.model.process.IConnection)149 ArrayList (java.util.ArrayList)79 INode (org.talend.core.model.process.INode)63 List (java.util.List)60 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)57 Node (org.talend.designer.core.ui.editor.nodes.Node)47 HashMap (java.util.HashMap)36 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)33 IElementParameter (org.talend.core.model.process.IElementParameter)31 Map (java.util.Map)25 Connection (org.talend.designer.core.ui.editor.connections.Connection)25 INodeConnector (org.talend.core.model.process.INodeConnector)24 Point (org.eclipse.swt.graphics.Point)13 Process (org.talend.designer.core.ui.editor.process.Process)13 IJobletProviderService (org.talend.core.ui.IJobletProviderService)12 HashSet (java.util.HashSet)11 MetadataTable (org.talend.core.model.metadata.MetadataTable)10 IProcess (org.talend.core.model.process.IProcess)10 ChangeMetadataCommand (org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand)9 IExternalNode (org.talend.core.model.process.IExternalNode)8