Search in sources :

Example 1 with IODataComponent

use of org.talend.core.model.components.IODataComponent in project tdi-studio-se by Talend.

the class MapperMain method initIOConnections.

public void initIOConnections(IODataComponentContainer ioDataContainer) {
    List<IODataComponent> inputsData = ioDataContainer.getInputs();
    List<IODataComponent> ouputsData = ioDataContainer.getOuputs();
    ioInputConnections = new ArrayList<IOConnection>(inputsData.size());
    for (IODataComponent iData : inputsData) {
        ioInputConnections.add(new IOConnection(iData));
    }
    ioOutputConnections = new ArrayList<IOConnection>(ouputsData.size());
    for (IODataComponent oData : ouputsData) {
        ioOutputConnections.add(new IOConnection(oData));
    }
}
Also used : IOConnection(org.talend.designer.dbmap.external.connection.IOConnection) IODataComponent(org.talend.core.model.components.IODataComponent)

Example 2 with IODataComponent

use of org.talend.core.model.components.IODataComponent in project tdi-studio-se by Talend.

the class MapperMain method createModelFromExternalData.

public void createModelFromExternalData(IODataComponentContainer ioDataContainer, List<IMetadataTable> outputMetadataTables, ExternalMapperData externalData, boolean checkProblems) {
    List<IODataComponent> inputsData = ioDataContainer.getInputs();
    List<IODataComponent> ouputsData = ioDataContainer.getOuputs();
    ArrayList<IOConnection> inputs = new ArrayList<IOConnection>(inputsData.size());
    for (IODataComponent iData : inputsData) {
        inputs.add(new IOConnection(iData));
    }
    ArrayList<IOConnection> outputs = new ArrayList<IOConnection>(ouputsData.size());
    for (IODataComponent oData : ouputsData) {
        outputs.add(new IOConnection(oData));
    }
    createModelFromExternalData(inputs, outputs, outputMetadataTables, externalData, false);
}
Also used : IOConnection(org.talend.designer.mapper.external.connection.IOConnection) ArrayList(java.util.ArrayList) IODataComponent(org.talend.core.model.components.IODataComponent)

Example 3 with IODataComponent

use of org.talend.core.model.components.IODataComponent in project tdi-studio-se by Talend.

the class InsertNewColumnCommand method createInputMetadataColumn.

private void createInputMetadataColumn(String sourceTreeName, String targetTreeName, TreeNode sourceNode, String targetNodeName, int index) {
    String sourceNodeName = sourceNode.getName();
    IMetadataTable metadataTarget = null;
    List<IODataComponent> inputs = manager.getMapperComponent().getIODataComponents().getInputs();
    for (IODataComponent incoming : inputs) {
        if (targetTreeName != null && targetTreeName.equals(incoming.getConnection().getName())) {
            metadataTarget = incoming.getTable();
        }
    }
    if (metadataTarget != null) {
        IMetadataColumn columnSource = null;
        if (sourceTreeName != null) {
            columnSource = getSourceColumn(sourceTreeName, sourceNodeName);
        }
        creatMeatadataColumn(columnSource, targetNodeName, sourceNode, metadataTarget, index);
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IODataComponent(org.talend.core.model.components.IODataComponent) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 4 with IODataComponent

use of org.talend.core.model.components.IODataComponent in project tdi-studio-se by Talend.

the class ExternalNodeChangeCommand method undo.

@Override
public void undo() {
    for (Connection connection : (List<Connection>) node.getIncomingConnections()) {
        if (connection.getLineStyle().equals(EConnectionType.FLOW_MAIN) || connection.getLineStyle().equals(EConnectionType.FLOW_REF) || connection.getLineStyle().equals(EConnectionType.TABLE) || connection.getLineStyle().equals(EConnectionType.TABLE_REF)) {
            IODataComponent currentIO = inAndOut.getDataComponent(connection);
            if (currentIO.hasChanged()) {
                // IMetadataTable metadata = inAndOut.getTable(connection);
                INode sourceNode = currentIO.getSource();
                sourceNode.metadataOutputChanged(currentIO, currentIO.getName());
                // IMetadataTable oldMetadata = connection.getMetadataTable().clone();
                // currentIO.setTable(oldMetadata);
                // connection.getMetadataTable().setListColumns(metadata.getListColumns());
                IMetadataTable oldMetadata = currentIO.getConnMetadataTable();
                // currentIO.setTable(oldMetadata);
                connection.getMetadataTable().setListColumns(oldMetadata.getListColumns());
                if (metadataInputWasRepository.get(connection) != null) {
                    connection.getSource().setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.REPOSITORY);
                }
            }
        }
    }
    metadataInputWasRepository.clear();
    node.setExternalData(oldExternalData);
    node.setMetadataList(oldMetaDataList);
    for (Connection connection : connectionsToDelete.keySet()) {
        connection.reconnect();
        Node prevNode = (Node) connection.getSource();
        INodeConnector nodeConnectorSource, nodeConnectorTarget;
        nodeConnectorSource = prevNode.getConnectorFromType(connection.getLineStyle());
        nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() + 1);
        Node nextNode = (Node) connection.getTarget();
        nodeConnectorTarget = nextNode.getConnectorFromType(connection.getLineStyle());
        nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() + 1);
        if (connectionsToDelete.get(connection) != null) {
            inAndOut.getOuputs().add(connectionsToDelete.get(connection));
        }
    }
    for (ChangeMetadataCommand cmd : metadataOutputChanges) {
        cmd.undo();
    }
    ((Process) node.getProcess()).checkProcess();
    if (!isMetaLanguage) {
        refreshCodeView();
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) List(java.util.List) Process(org.talend.designer.core.ui.editor.process.Process) IODataComponent(org.talend.core.model.components.IODataComponent) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 5 with IODataComponent

use of org.talend.core.model.components.IODataComponent in project tdi-studio-se by Talend.

the class ExternalNodeChangeCommand method propagateInput.

private void propagateInput() {
    for (Connection connection : (List<Connection>) node.getIncomingConnections()) {
        if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
            IODataComponent currentIO = inAndOut.getDataComponent(connection);
            currentIO.setColumnOption(IMetadataColumn.OPTIONS_NONE);
            if (currentIO.hasChanged()) {
                IMetadataTable metadata = inAndOut.getTable(connection);
                INode sourceNode = currentIO.getSource();
                sourceNode.metadataOutputChanged(currentIO, currentIO.getName());
                // It's better to clone, because will change that, if apply, bug 13325
                // IMetadataTable oldMetadata = connection.getMetadataTable().clone();
                IMetadataTable newMetadata = metadata.clone();
                currentIO.setTable(newMetadata);
                String schemaType = (String) connection.getSource().getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
                if (schemaType != null) {
                    // if there is a SCHEMA_TYPE, then switch it to BUILT_IN if REPOSITORY is set.
                    if (schemaType.equals(EmfComponent.REPOSITORY)) {
                        connection.getSource().setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
                        metadataInputWasRepository.put(connection, Boolean.TRUE);
                    }
                }
                // for bug 9849
                List<IMetadataColumn> listColumns = connection.getMetadataTable().getListColumns();
                // before is empty
                boolean empty = listColumns.isEmpty();
                List<IMetadataColumn> newListColumns = newMetadata.getListColumns();
                List<ColumnNameChanged> columnNameChangeds = new ArrayList<ColumnNameChanged>();
                int size = listColumns.size();
                int newSize = newListColumns.size();
                if (newSize < size) {
                    size = newSize;
                }
                for (int i = 0; i < size; i++) {
                    IMetadataColumn metadataColumn = listColumns.get(i);
                    IMetadataColumn newMetadataColumn = newListColumns.get(i);
                    if (metadataColumn != null && newMetadataColumn != null) {
                        String oldId = metadataColumn.getId();
                        String oldLabel = metadataColumn.getLabel();
                        String newLabel = newMetadataColumn.getLabel();
                        String newId = newMetadataColumn.getId();
                        if (oldId != null && oldLabel != null && newId != null && oldId.equals(newId) && !oldLabel.equals(newLabel)) {
                            columnNameChangeds.add(new ColumnNameChanged(oldLabel, newLabel));
                        }
                    }
                }
                connection.getMetadataTable().setListColumns(newListColumns);
                // some pig component have FLOW_MAIN && PIGCOMBINE two connector type
                if (connection.getConnectorName() != null && connection.getConnectorName().equals("PIGCOMBINE")) {
                    IMetadataTable table = sourceNode.getMetadataFromConnector(EConnectionType.FLOW_MAIN.getName());
                    if (table != null) {
                        table.setListColumns(newListColumns);
                    }
                }
                ColumnListController.updateColumnList(sourceNode, columnNameChangeds, false);
                if (empty) {
                    // trace init
                    connection.initTraceParamters();
                }
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ColumnNameChanged(org.talend.core.model.metadata.ColumnNameChanged) ArrayList(java.util.ArrayList) List(java.util.List) IODataComponent(org.talend.core.model.components.IODataComponent)

Aggregations

IODataComponent (org.talend.core.model.components.IODataComponent)20 IConnection (org.talend.core.model.process.IConnection)11 ArrayList (java.util.ArrayList)10 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)10 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)7 List (java.util.List)6 IODataComponentContainer (org.talend.core.model.components.IODataComponentContainer)6 INode (org.talend.core.model.process.INode)5 Connection (org.talend.designer.core.ui.editor.connections.Connection)5 Node (org.talend.designer.core.ui.editor.nodes.Node)4 IExternalNode (org.talend.core.model.process.IExternalNode)3 INodeConnector (org.talend.core.model.process.INodeConnector)3 HashMap (java.util.HashMap)2 ColumnNameChanged (org.talend.core.model.metadata.ColumnNameChanged)2 Process (org.talend.designer.core.ui.editor.process.Process)2 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)2 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 EList (org.eclipse.emf.common.util.EList)1