Search in sources :

Example 1 with IConnection

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

the class PostgresGenerationManager method getHandledTableName.

protected String getHandledTableName(DbMapComponent component, String name, String aliasName, boolean generateSubSql) {
    List<IConnection> inputConnections = (List<IConnection>) component.getIncomingConnections();
    if (inputConnections == null) {
        return name;
    }
    for (IConnection iconn : inputConnections) {
        boolean inputIsELTDBMap = false;
        INode source = iconn.getSource();
        String schemaStr = "";
        String tableNameStr = "";
        if (source != null) {
            inputIsELTDBMap = isELTDBMap(source);
            if (inputIsELTDBMap) {
                tableNameStr = iconn.getName();
            } else {
                IElementParameter schema = source.getElementParameter("ELT_SCHEMA_NAME");
                IElementParameter tableName = source.getElementParameter("ELT_TABLE_NAME");
                if (schema != null && schema.getValue() != null) {
                    schemaStr = TalendTextUtils.removeQuotes(schema.getValue().toString());
                }
                if (tableName != null && tableName.getValue() != null) {
                    tableNameStr = TalendTextUtils.removeQuotes(tableName.getValue().toString());
                }
            }
        }
        String tableName = schemaStr;
        if ("".equals(tableName)) {
            tableName = tableNameStr;
        } else {
            if (!"".equals(tableNameStr)) {
                tableName = tableName + "." + tableNameStr;
            }
        }
        if (tableName.equals(name)) {
            StringBuffer sb = new StringBuffer();
            if (inputIsELTDBMap && generateSubSql) {
                DbMapComponent externalNode = null;
                if (source instanceof DbMapComponent) {
                    externalNode = (DbMapComponent) source;
                } else {
                    externalNode = (DbMapComponent) source.getExternalNode();
                }
                DbGenerationManager genManager = externalNode.getGenerationManager();
                String deliveredTable = genManager.buildSqlSelect(externalNode, iconn.getMetadataTable().getTableName(), //$NON-NLS-1$
                tabSpaceString + "  ");
                int begin = 1;
                int end = deliveredTable.length() - 1;
                if (begin <= end) {
                    //$NON-NLS-1$ //$NON-NLS-2$
                    sb.append("(").append(DbMapSqlConstants.NEW_LINE).append(tabSpaceString).append("  ");
                    sb.append(deliveredTable.substring(begin, end)).append(DbMapSqlConstants.NEW_LINE).append(tabSpaceString).append(//$NON-NLS-1$
                    " ) ");
                }
                if (aliasName != null && !aliasName.trim().isEmpty()) {
                    tableNameStr = aliasName;
                }
            }
            StringBuffer tempExp = getSchemaAndTable(schemaStr, tableNameStr);
            sb.append(tempExp);
            return sb.toString();
        }
    }
    return name;
}
Also used : INode(org.talend.core.model.process.INode) DbMapComponent(org.talend.designer.dbmap.DbMapComponent) DbGenerationManager(org.talend.designer.dbmap.language.generation.DbGenerationManager) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) IConnection(org.talend.core.model.process.IConnection)

Example 2 with IConnection

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

the class ScdManager method getInputColumns.

public List<IMetadataColumn> getInputColumns(INode node) {
    List<IMetadataColumn> inputSchema = Collections.emptyList();
    List<? extends IConnection> incomingConnections = node.getIncomingConnections();
    if (incomingConnections != null && incomingConnections.size() > 0) {
        for (IConnection incomingConnection : incomingConnections) {
            if (incomingConnection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
                IMetadataTable schemaTable = incomingConnection.getMetadataTable();
                if (schemaTable != null) {
                    inputSchema = schemaTable.getListColumns();
                }
            }
        }
    }
    return inputSchema;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IConnection(org.talend.core.model.process.IConnection) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 3 with IConnection

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

the class ConnectionCreateAction method canPerformAction.

/**
     * Test if the selected item is a node.
     * 
     * @return true/false
     */
@SuppressWarnings("unchecked")
private boolean canPerformAction() {
    if (getSelectedObjects().isEmpty()) {
        return false;
    }
    List parts = getSelectedObjects();
    if (parts.size() == 1) {
        Object o = parts.get(0);
        if (!(o instanceof NodePart)) {
            return false;
        }
        nodePart = (NodePart) o;
        if (!(nodePart.getModel() instanceof Node)) {
            return false;
        }
        Node node = (Node) nodePart.getModel();
        if (!node.isActivate()) {
            return false;
        }
        if (node.getJobletNode() != null) {
            return false;
        }
        if (curNodeConnector != null && "VALIDATION_REJECT".equals(curNodeConnector.getName())) {
            if (node.getProcess() != null && !ComponentCategory.CATEGORY_4_DI.getName().equals(node.getProcess().getComponentsType())) {
                return false;
            }
        }
        if (connecType.hasConnectionCategory(IConnectionCategory.EXECUTION_ORDER)) {
            if (!(Boolean) node.getPropertyValue(EParameterName.STARTABLE.getName()) || (!node.getProcessStartNode(false).equals(node))) {
                if (!node.isELTMapComponent()) {
                    boolean jobletOk = false;
                    if (PluginChecker.isJobLetPluginLoaded()) {
                        IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                        if (service != null && service.isJobletComponent(node)) {
                            jobletOk = true;
                        }
                    }
                    if (!jobletOk) {
                        return false;
                    }
                }
            }
        }
        menuList = new ArrayList<String>();
        if (curNodeConnector == null) {
            curNodeConnector = node.getConnectorFromType(connecType);
            if (curNodeConnector == null) {
                return false;
            }
        }
        if (curNodeConnector.getMaxLinkOutput() != -1) {
            if (curNodeConnector.getCurLinkNbOutput() >= curNodeConnector.getMaxLinkOutput()) {
                return false;
            }
        }
        if (curNodeConnector.getMaxLinkOutput() == 0) {
            return false;
        }
        /**
             * judge whether to show the table link menu in ELTMap components
             */
        if (curNodeConnector.getName().equals(EConnectionType.TABLE.getName())) {
            List<? extends IConnection> tableRefs = node.getOutgoingConnections(EConnectionType.TABLE_REF);
            if (tableRefs != null && 0 < tableRefs.size()) {
                return false;
            }
        }
        if (!curNodeConnector.isMultiSchema()) {
        // setText(curNodeConnector.getMenuName());
        }
        if (curNodeConnector.isMultiSchema()) {
            for (int i = 0; i < node.getMetadataList().size(); i++) {
                IMetadataTable table = (node.getMetadataList().get(i));
                String value = table.getAdditionalProperties().get(ISINPUT);
                if (value != null && value.equals(TRUE)) {
                    continue;
                }
                String name = table.getTableName();
                if (name.equals(node.getUniqueName())) {
                    continue;
                }
                if (table.getAttachedConnector() == null || table.getAttachedConnector().equals(curNodeConnector.getName())) {
                    if (connecType == EConnectionType.TABLE) {
                        //$NON-NLS-1$ //$NON-NLS-2$
                        name = table.getLabel() + " (" + name + ")";
                    }
                    boolean nameUsed = false;
                    for (Connection connec : (List<Connection>) node.getOutgoingConnections()) {
                        if (connec.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
                            if (connec.getMetadataTable().getTableName().equals(table.getTableName())) {
                                nameUsed = true;
                            }
                        }
                    }
                    // if the name is not already in the process adds to the list
                    if (!nameUsed) {
                        menuList.add(name);
                    }
                }
            }
            if ((curNodeConnector.getMaxLinkOutput() == -1 || node.getMetadataList().size() < curNodeConnector.getMaxLinkOutput()) && curNodeConnector.isBuiltIn()) {
                menuList.add(getNewOutputMenuName());
            }
        } else {
            String menuName;
            boolean addDefaultName = false;
            // get linked metadata to connector
            IMetadataTable table = null;
            for (int i = 0; i < node.getMetadataList().size(); i++) {
                table = (node.getMetadataList().get(i));
                if (table.getTableName().equals(node.getUniqueName())) {
                    break;
                }
            }
            // if EBCDIC + single schema mode, only have one output maximum
            if (node.getComponent().getName().contains("EBCDIC") && node.checkSchemaForEBCDIC(table) && curNodeConnector.getCurLinkNbOutput() > 0) {
                return false;
            }
            if (connecType == EConnectionType.TABLE) {
                addDefaultName = addDefaultName();
                menuName = getNewOutputMenuName();
            } else {
                menuName = curNodeConnector.getMenuName();
            }
            if (!addDefaultName) {
                setText(menuName);
                menuList.add(menuName);
            }
        }
        return true;
    }
    return false;
}
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) Point(org.eclipse.draw2d.geometry.Point) IJobletProviderService(org.talend.core.ui.IJobletProviderService) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 4 with IConnection

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

the class ModifyMergeOrderAction method calculateEnabled.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
     */
@Override
protected boolean calculateEnabled() {
    if (getSelectedObjects().isEmpty()) {
        return false;
    }
    List parts = getSelectedObjects();
    if (parts.size() != 1) {
        return false;
    }
    Object o = parts.get(0);
    INode node = null;
    if (o instanceof ConnectionPart) {
        ConnectionPart part = (ConnectionPart) o;
        IConnection connection = (IConnection) part.getModel();
        node = connection.getTarget();
    } else if (o instanceof ConnLabelEditPart) {
        ConnectionPart part = (ConnectionPart) ((ConnLabelEditPart) o).getParent();
        Connection connection = (Connection) part.getModel();
        node = connection.getTarget();
    } else if (o instanceof NodePart) {
        node = (Node) ((NodePart) o).getModel();
    }
    if ((node == null) || (!node.getComponent().useMerge())) {
        return false;
    }
    mergeComponent = node;
    setText(TEXT_MERGE_ORDER);
    return true;
}
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) List(java.util.List) IConnection(org.talend.core.model.process.IConnection) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 5 with IConnection

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

the class TracesConnectionUtils method setTraceFilterParameters.

/**
     * DOC wzhang Comment method "setTraceFilterParameters".
     */
public static void setTraceFilterParameters(INode node, IMetadataTable table, Set<String> preColumnSet, Map<String, String> changedNameColumns) {
    if (node != null && table != null && preColumnSet != null) {
        IConnection curConnection = getConnection(node.getOutgoingConnections(), table);
        if (curConnection != null) {
            Set<String> addedColumns = new HashSet<String>();
            for (IMetadataColumn curColumn : table.getListColumns()) {
                if (!(preColumnSet.contains(curColumn.getLabel()))) {
                    addedColumns.add(curColumn.getLabel());
                }
            }
            CorePlugin.getDefault().getDesignerCoreService().updateTraceColumnValues(curConnection, changedNameColumns, addedColumns);
        }
    }
}
Also used : IConnection(org.talend.core.model.process.IConnection) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) HashSet(java.util.HashSet)

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