Search in sources :

Example 91 with IConnection

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

the class XMLMapperHelper method hasAllInOne.

private static boolean hasAllInOne(final INode xmlMapperNode) {
    boolean hasAllInOne = false;
    List<? extends IConnection> outConnections = (List<? extends IConnection>) xmlMapperNode.getOutgoingConnections();
    XmlMapData xmlMapData = (XmlMapData) ElementParameterParser.getObjectValueXMLTree(xmlMapperNode);
    if (xmlMapData != null && outConnections != null && outConnections.size() > 0) {
        List<OutputXmlTree> outputTables = xmlMapData.getOutputTrees();
        HashMap<String, IConnection> hNameToConnection = new HashMap<String, IConnection>();
        for (IConnection connection : outConnections) {
            hNameToConnection.put(connection.getName(), connection);
        }
        for (OutputXmlTree outputTable : outputTables) {
            String tableName = outputTable.getName();
            IConnection connection = hNameToConnection.get(tableName);
            if (connection == null) {
                continue;
            }
            if (outputTable.isAllInOne()) {
                hasAllInOne = true;
                break;
            }
        }
    }
    return hasAllInOne;
}
Also used : HashMap(java.util.HashMap) EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) List(java.util.List) IConnection(org.talend.core.model.process.IConnection) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 92 with IConnection

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

Example 93 with IConnection

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

the class FOXMain method createUI.

/**
     * create UI".
     * 
     * @param parent
     * @return
     */
public void createUI(Composite parent) {
    if (!connector.istWriteXMLField() && !connector.istMDMOutput()) {
        IConnection inConn = null;
        List<? extends IConnection> incomeConnections = connector.getIncomingConnections();
        if (connector.istFileOutputMSXML() && incomeConnections.size() < 1) {
            MessageBox message = new MessageBox(parent.getShell(), SWT.APPLICATION_MODAL | SWT.OK);
            //$NON-NLS-1$
            message.setText(Messages.getString("FOXMain.inputlinkError"));
            //$NON-NLS-1$
            message.setMessage(Messages.getString("FOXMain.noInputLink"));
            if (message.open() == SWT.OK) {
                ((Shell) parent).close();
                return;
            }
            for (IConnection conn : incomeConnections) {
                if ((conn.getLineStyle().equals(EConnectionType.FLOW_MAIN)) || (conn.getLineStyle().equals(EConnectionType.FLOW_REF))) {
                    inConn = conn;
                    break;
                }
            }
            if (inConn != null) {
                if (!inConn.getMetadataTable().sameMetadataAs(connector.getMetadataList().get(0))) {
                    MessageBox messageBox = new MessageBox(parent.getShell(), SWT.APPLICATION_MODAL | SWT.OK);
                    //$NON-NLS-1$
                    messageBox.setText(Messages.getString("FOXMain.0"));
                    //$NON-NLS-1$
                    messageBox.setMessage(Messages.getString("FOXMain.1"));
                    if (messageBox.open() == SWT.OK) {
                        ((Shell) parent).close();
                        return;
                    }
                }
            }
        }
    }
    // add by wzhang. for component tFileOutputMSXML
    if (connector.istFileOutputMSXML()) {
        generatorUI = new FOXMultiSchemaUI(parent, foxManager);
    } else {
        generatorUI = new FOXUI(parent, foxManager);
    }
    generatorUI.init();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) FOXMultiSchemaUI(org.talend.designer.fileoutputxml.ui.FOXMultiSchemaUI) IConnection(org.talend.core.model.process.IConnection) FOXUI(org.talend.designer.fileoutputxml.ui.FOXUI) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 94 with IConnection

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

the class MultiFOXManager method getMultiSchemaData.

public List<IMetadataTable> getMultiSchemaData() {
    List<IMetadataTable> schemas = new ArrayList<IMetadataTable>();
    List<? extends IConnection> incomingConnections = NodeUtil.getIncomingConnections(foxComponent, IConnectionCategory.FLOW);
    for (IConnection connection : incomingConnections) {
        connection.getMetadataTable().setLabel(connection.getUniqueName());
        schemas.add(connection.getMetadataTable());
    }
    return schemas;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection)

Example 95 with IConnection

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

the class FOXManager method initModel.

public void initModel() {
    IMetadataTable metadataTable = foxComponent.getMetadataTable();
    if (metadataTable == null) {
        metadataTable = new MetadataTable();
    }
    String componentName = foxComponent.getComponent().getName();
    //        if (componentName.equals("tWriteXMLField")) { //$NON-NLS-1$ //$NON-NLS-2$
    IConnection inConn = null;
    for (IConnection conn : foxComponent.getIncomingConnections()) {
        if ((conn.getLineStyle().equals(EConnectionType.FLOW_MAIN)) || (conn.getLineStyle().equals(EConnectionType.FLOW_REF))) {
            inConn = conn;
            break;
        }
    }
    if (inConn != null) {
        metadataTable = inConn.getMetadataTable();
    }
    // }
    treeData = new ArrayList<FOXTreeNode>();
    FOXTreeNode rootNode = null;
    FOXTreeNode current = null;
    FOXTreeNode temp = null;
    FOXTreeNode mainNode = null;
    String mainPath = null;
    String currentPath = null;
    String defaultValue = null;
    int nodeOrder = 0;
    boolean haveOrder = true;
    // build root tree
    List<Map<String, String>> rootTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.ROOT);
    for (Map<String, String> rootMap : rootTable) {
        String newPath = rootMap.get(FileOutputXMLComponent.PATH);
        defaultValue = rootMap.get(FileOutputXMLComponent.VALUE);
        String orderValue = rootMap.get(FileOutputXMLComponent.ORDER);
        if (orderValue == null || "".equals(orderValue)) {
            haveOrder = false;
        }
        if (haveOrder) {
            nodeOrder = Integer.valueOf(rootMap.get(FileOutputXMLComponent.ORDER)).intValue();
        }
        if (rootMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("attri")) {
            //$NON-NLS-1$
            temp = new Attribute(newPath);
            temp.setDefaultValue(defaultValue);
            temp.setAttribute(true);
            current.addChild(temp);
        } else if (rootMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("ns")) {
            //$NON-NLS-1$
            temp = new NameSpaceNode(newPath);
            temp.setDefaultValue(defaultValue);
            temp.setNameSpace(true);
            current.addChild(temp);
        } else {
            temp = this.addElement(current, currentPath, newPath, defaultValue);
            if (rootNode == null) {
                rootNode = temp;
            }
            if (rootMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("main")) {
                //$NON-NLS-1$
                temp.setMain(true);
                mainNode = temp;
                mainPath = newPath;
            }
            current = temp;
            currentPath = newPath;
        }
        if (haveOrder) {
            temp.setOrder(nodeOrder);
        }
        String columnName = rootMap.get(FileOutputXMLComponent.COLUMN);
        if (columnName != null && columnName.length() > 0) {
            temp.setColumn(metadataTable.getColumn(columnName));
        }
    }
    // build group tree
    current = mainNode;
    currentPath = mainPath;
    boolean isFirst = true;
    List<Map<String, String>> groupTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.GROUP);
    for (Map<String, String> groupMap : groupTable) {
        String newPath = groupMap.get(FileOutputXMLComponent.PATH);
        defaultValue = groupMap.get(FileOutputXMLComponent.VALUE);
        String orderValue = groupMap.get(FileOutputXMLComponent.ORDER);
        if (orderValue == null || "".equals(orderValue)) {
            haveOrder = false;
        }
        if (haveOrder) {
            nodeOrder = Integer.valueOf(groupMap.get(FileOutputXMLComponent.ORDER)).intValue();
        }
        if (groupMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("attri")) {
            //$NON-NLS-1$
            temp = new Attribute(newPath);
            temp.setDefaultValue(defaultValue);
            temp.setAttribute(true);
            current.addChild(temp);
        } else if (groupMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("ns")) {
            //$NON-NLS-1$
            temp = new NameSpaceNode(newPath);
            temp.setDefaultValue(defaultValue);
            temp.setNameSpace(true);
            current.addChild(temp);
        } else {
            temp = this.addElement(current, currentPath, newPath, defaultValue);
            if (groupMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("main")) {
                //$NON-NLS-1$
                temp.setMain(true);
                mainNode = temp;
                mainPath = newPath;
            }
            if (isFirst) {
                temp.setGroup(true);
                isFirst = false;
            }
            current = temp;
            currentPath = newPath;
        }
        if (haveOrder) {
            temp.setOrder(nodeOrder);
        }
        String columnName = groupMap.get(FileOutputXMLComponent.COLUMN);
        if (columnName != null && columnName.length() > 0) {
            temp.setColumn(metadataTable.getColumn(columnName));
        }
    }
    // build loop tree
    current = mainNode;
    currentPath = mainPath;
    isFirst = true;
    List<Map<String, String>> loopTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.LOOP);
    for (Map<String, String> loopMap : loopTable) {
        String newPath = loopMap.get(FileOutputXMLComponent.PATH);
        defaultValue = loopMap.get(FileOutputXMLComponent.VALUE);
        String orderValue = loopMap.get(FileOutputXMLComponent.ORDER);
        if (orderValue == null || "".equals(orderValue)) {
            haveOrder = false;
        }
        if (haveOrder) {
            nodeOrder = Integer.valueOf(loopMap.get(FileOutputXMLComponent.ORDER)).intValue();
        }
        if (loopMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("attri")) {
            //$NON-NLS-1$
            temp = new Attribute(newPath);
            temp.setDefaultValue(defaultValue);
            temp.setAttribute(true);
            current.addChild(temp);
        } else if (loopMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("ns")) {
            //$NON-NLS-1$
            temp = new NameSpaceNode(newPath);
            temp.setDefaultValue(defaultValue);
            temp.setNameSpace(true);
            current.addChild(temp);
        } else {
            temp = this.addElement(current, currentPath, newPath, defaultValue);
            if (rootNode == null) {
                rootNode = temp;
            }
            if (loopMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("main")) {
                //$NON-NLS-1$
                temp.setMain(true);
            }
            if (isFirst) {
                temp.setLoop(true);
                isFirst = false;
            }
            current = temp;
            currentPath = newPath;
        }
        if (haveOrder) {
            temp.setOrder(nodeOrder);
        }
        String columnName = loopMap.get(FileOutputXMLComponent.COLUMN);
        if (columnName != null && columnName.length() > 0) {
            temp.setColumn(metadataTable.getColumn(columnName));
        }
    }
    if (rootNode == null) {
        //$NON-NLS-1$
        rootNode = new Element("rootTag");
    }
    rootNode.setParent(null);
    if (haveOrder) {
        orderNode(rootNode);
    }
    treeData.add(rootNode);
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) Attribute(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element) IConnection(org.talend.core.model.process.IConnection) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) NameSpaceNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

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