Search in sources :

Example 86 with IMetadataColumn

use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.

the class OracleGenerationManagerTest method createColumn.

private IMetadataColumn createColumn(String label) {
    IMetadataColumn column = new MetadataColumn();
    // will be error, strange
    // when(column.getLabel()).thenReturn(label);
    column.setLabel(label);
    column.setOriginalDbColumnName(label);
    return column;
}
Also used : IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 87 with IMetadataColumn

use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.

the class PostgresGenerationManagerTest method mockConnection.

private IConnection mockConnection(String schemaName, String tableName, String[] columns) {
    Connection connection = mock(Connection.class);
    Node node = mock(Node.class);
    ElementParameter param = new ElementParameter(node);
    param.setName("ELT_SCHEMA_NAME");
    param.setValue(schemaName);
    when(node.getElementParameter("ELT_SCHEMA_NAME")).thenReturn(param);
    param = new ElementParameter(node);
    param.setName("ELT_TABLE_NAME");
    param.setValue(tableName);
    when(node.getElementParameter("ELT_TABLE_NAME")).thenReturn(param);
    when(connection.getName()).thenReturn(schemaName + "." + tableName);
    when(connection.getSource()).thenReturn(node);
    IMetadataTable table = new MetadataTable();
    table.setLabel(tableName);
    table.setTableName(tableName);
    List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
    for (String columnName : columns) {
        IMetadataColumn column = new MetadataColumn();
        column.setLabel(columnName);
        column.setOriginalDbColumnName(columnName);
        listColumns.add(column);
    }
    table.setListColumns(listColumns);
    when(connection.getMetadataTable()).thenReturn(table);
    return connection;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) ElementParameter(org.talend.designer.core.model.components.ElementParameter) 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) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 88 with IMetadataColumn

use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.

the class DbGenerationManagerTest method createConnection.

private IConnection createConnection(String schemaName, String tableName, String label, String[] columns) {
    Connection connection = mock(Connection.class);
    when(connection.getName()).thenReturn(tableName);
    IMetadataTable metadataTable = new MetadataTable();
    metadataTable.setLabel(tableName);
    metadataTable.setTableName(tableName);
    List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
    for (String columnName : columns) {
        IMetadataColumn column = new MetadataColumn();
        column.setLabel(label);
        column.setOriginalDbColumnName(columnName);
        listColumns.add(column);
    }
    metadataTable.setListColumns(listColumns);
    when(connection.getMetadataTable()).thenReturn(metadataTable);
    return connection;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 89 with IMetadataColumn

use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.

the class WebServiceDialog method saveValue.

private void saveValue() {
    List<InputMappingData> inputList = webServiceUI.getInputParams();
    List<OutPutMappingData> outputList = webServiceUI.getOutputParams();
    String currentURL = webServiceUI.getURL();
    List<PortNames> allPortNames = webServiceUI.getAllPortNames();
    Function function = webServiceUI.getCurrentFunction();
    PortNames currePortName = webServiceUI.getCurrentPortName();
    List<OutPutMappingData> outEleList = webServiceUI.getOutputElement();
    Set<String> insourceList = webServiceUI.getInSourceList();
    Set<String> outsourceList = webServiceUI.getOutSourceList();
    IMetadataTable inputMetaCopy = webServiceUI.getInputMetaCopy();
    IMetadataTable outputMetaCopy = webServiceUI.getOutputMetaCopy();
    IMetadataTable inputMetadata = webServiceUI.getInputMetadata();
    IMetadataTable outputMetadata = webServiceUI.getOutputMetadata();
    List<IMetadataColumn> inputmetadata = webServiceUI.getInputValue();
    WebServiceComponent wenCom = webServiceComponentMain.getWebServiceComponent();
    IMetadataTable wenMetadata = wenCom.getMetadataFromConnector("OUTPUT");
    if (wenMetadata != null && outputMetadata != wenMetadata) {
        outputMetadata = wenMetadata;
    }
    // save schema.
    if (outputMetaCopy != null) {
        if (!outputMetaCopy.sameMetadataAs(outputMetadata, IMetadataColumn.OPTIONS_NONE)) {
            outputMetadata.getListColumns().clear();
            outputMetadata.getListColumns().addAll(outputMetaCopy.getListColumns());
        }
    }
    if (!"".equals(currentURL) && currentURL != null) {
        IElementParameter ENDPOINTPara = wenCom.getElementParameter("ENDPOINT");
        ENDPOINTPara.setValue(currentURL);
    }
    if (currePortName != null) {
        IElementParameter Port_Name = wenCom.getElementParameter("PORT_NAME");
        Port_Name.setValue(currePortName.getPortName());
    } else if (currePortName == null && !allPortNames.isEmpty()) {
        currePortName = allPortNames.get(0);
        IElementParameter Port_Name = wenCom.getElementParameter("PORT_NAME");
        Port_Name.setValue(currePortName.getPortName());
    }
    if (function != null) {
        if (function.getName() != null) {
            IElementParameter METHODPara = wenCom.getElementParameter("METHOD");
            METHODPara.setValue(function.getName());
        }
        if (function.getServerNameSpace() != null) {
            IElementParameter Service_NS = wenCom.getElementParameter("SERVICE_NS");
            Service_NS.setValue(function.getServerNameSpace());
        }
        if (function.getServerName() != null) {
            IElementParameter Service_Name = wenCom.getElementParameter("SERVICE_NAME");
            Service_Name.setValue(function.getServerName());
        }
        if (function.getServerNameSpace() != null) {
            IElementParameter Port_NS = wenCom.getElementParameter("PORT_NS");
            Port_NS.setValue(function.getServerNameSpace());
        }
    // IElementParameter ADDRESSLocation = wenCom.getElementParameter("ADDRESS_LOCATION");
    // ADDRESSLocation.setValue(function.getAddressLocation());
    }
    // save input
    IElementParameter INPUT_PARAMSPara = wenCom.getElementParameter("INPUT_PARAMS");
    List<Map<String, String>> inputparaValue = (List<Map<String, String>>) INPUT_PARAMSPara.getValue();
    if (inputparaValue == null) {
        inputparaValue = new ArrayList<Map<String, String>>();
    } else {
        inputparaValue.clear();
    }
    for (InputMappingData inputData : inputList) {
        Map<String, String> inputMap = new HashMap<String, String>(2);
        if (inputData.getInputColumnValue() != null) {
            inputMap.put("EXPRESSION", inputData.getInputColumnValue());
        }
        if (inputData.getParameterName() != null) {
            String name = inputData.getParameterName();
            if (!name.equals("")) {
                inputMap.put("ELEMENT", name);
            }
        } else if (inputData.getParameterName() == null && inputData.getParameter() != null) {
            if (inputData.getParameter().getParent() != null) {
                String name = new ParameterInfoUtil().getParentName(inputData.getParameter());
                inputMap.put("ELEMENT", name);
            } else {
                inputMap.put("ELEMENT", inputData.getParameter().getName());
            }
        // inputMap.put("ELEMENT", inputData.getInputElementValue());
        // inputMap.put("NAMESPACE", inputData.getParameter().getNameSpace());
        // inputMap.put("TYPE", inputData.getParameter().getKind());
        }
        inputparaValue.add(inputMap);
    }
    for (IMetadataColumn column : inputmetadata) {
        Map<String, String> columnMap = new HashMap<String, String>(1);
        if (column.getLabel() != null) {
            columnMap.put("COLUMN", column.getLabel());
            inputparaValue.add(columnMap);
        }
    }
    for (String insource : insourceList) {
        if (insource == null || "".equals(insource)) {
            continue;
        }
        Map<String, String> sourceMap = new HashMap<String, String>(1);
        sourceMap.put("SOURCE", insource);
        inputparaValue.add(sourceMap);
    }
    List<ParameterInfo> listParamter = new ArrayList();
    if (function != null) {
        List inputParameter = function.getInputParameters();
        if (inputParameter != null) {
            // for (int i = 0; i < inputParameter.size(); i++) {
            boolean mark = true;
            goin: for (Iterator iterator2 = inputParameter.iterator(); iterator2.hasNext(); ) {
                ParameterInfo element = (ParameterInfo) iterator2.next();
                Map<String, String> sourceMap = new HashMap<String, String>(2);
                sourceMap.put("PARAMETERINFO", element.getName());
                if (element.getParent() == null) {
                    sourceMap.put("PARAPARENT", "");
                } else {
                    sourceMap.put("PARAPARENT", element.getParent().getName());
                }
                inputparaValue.add(sourceMap);
                mark = false;
                if (!element.getParameterInfos().isEmpty()) {
                    listParamter.addAll(new ParameterInfoUtil().getAllChildren(element));
                }
                break goin;
            }
            if (!mark) {
                for (ParameterInfo para : listParamter) {
                    Map<String, String> sourceMap = new HashMap<String, String>(2);
                    sourceMap.put("PARAMETERINFO", para.getName());
                    sourceMap.put("PARAPARENT", para.getParent().getName());
                    sourceMap.put("PARAMETERARRAYSIZE", String.valueOf(para.getArraySize()));
                    sourceMap.put("PARAMETERINDEX", para.getIndex());
                    inputparaValue.add(sourceMap);
                }
            }
        // }
        }
    }
    // save output
    IElementParameter OUTPUT_PARAMSPara = wenCom.getElementParameter("OUTPUT_PARAMS");
    List<Map<String, String>> outputMap = (List<Map<String, String>>) OUTPUT_PARAMSPara.getValue();
    if (outputMap == null) {
        outputMap = new ArrayList<Map<String, String>>();
    } else {
        outputMap.clear();
    }
    for (OutPutMappingData outData : outEleList) {
        ParameterInfo para = outData.getParameter();
        if (para.getName() == null || "".equals(para.getName())) {
            continue;
        }
        Map<String, String> eleMap = new HashMap<String, String>(3);
        if (outData.getParameterName() != null) {
            eleMap.put("ELEMENT", outData.getParameterName());
        } else {
            eleMap.put("ELEMENT", para.getName());
        }
        // eleMap.put("NAMESPACE", para.getNameSpace());
        // eleMap.put("TYPE", para.getKind());
        outputMap.add(eleMap);
    }
    for (OutPutMappingData data : outputList) {
        Map<String, String> dataMap = new HashMap<String, String>(2);
        if (data.getParameterName() != null) {
            dataMap.put("EXPRESSION", data.getParameterName());
        } else if (data.getParameterName() == null) {
        // warningDialog("Please Select a Output Item.");
        // return;
        }
        if (data.getMetadataColumn() != null) {
            dataMap.put("COLUMN", data.getMetadataColumn().getLabel());
        }
        // else if (data.getMetadataColumn() == null) {
        // warningDialog("Please Select a Output Item.");
        // return;
        // }
        // Map<String, String> dataMap2 = new HashMap<String, String>(2);
        // if (data.getParameterList().size() > 0) {
        // for (ParameterInfo para : data.getParameterList()) {
        // dataMap2.put("", para.getNameSpace());
        // dataMap2.put("", para.getKind());
        // }
        // }
        //
        // if (data.getOutputColumnValue() != null) {
        // dataMap.put(data.getParameterName(), data.getOutputColumnValue());
        // }
        outputMap.add(dataMap);
    // outputMap.add(dataMap2);
    }
    for (String outsource : outsourceList) {
        if (outsource == null || "".equals(outsource)) {
            continue;
        }
        Map<String, String> sourceMap = new HashMap<String, String>(1);
        sourceMap.put("SOURCE", outsource);
        outputMap.add(sourceMap);
    }
    List<ParameterInfo> ls = new ArrayList();
    if (function != null) {
        List inputParameter = function.getOutputParameters();
        if (inputParameter != null) {
            // for (int i = 0; i < inputParameter.size(); i++) {
            boolean mark = true;
            goin: for (Iterator iterator2 = inputParameter.iterator(); iterator2.hasNext(); ) {
                ParameterInfo element = (ParameterInfo) iterator2.next();
                Map<String, String> sourceMap = new HashMap<String, String>(1);
                sourceMap.put("PARAMETERINFO", element.getName());
                if (element.getParent() == null) {
                    sourceMap.put("PARAPARENT", "");
                } else {
                    sourceMap.put("PARAPARENT", element.getParent().getName());
                }
                outputMap.add(sourceMap);
                mark = false;
                if (!element.getParameterInfos().isEmpty()) {
                    ls.addAll(new ParameterInfoUtil().getAllChildren(element));
                }
                break goin;
            }
            if (!mark) {
                for (ParameterInfo para : ls) {
                    Map<String, String> sourceMap = new HashMap<String, String>(2);
                    sourceMap.put("PARAMETERINFO", para.getName());
                    sourceMap.put("PARAPARENT", para.getParent().getName());
                    sourceMap.put("PARAMETERARRAYSIZE", String.valueOf(para.getArraySize()));
                    sourceMap.put("PARAMETERINDEX", para.getIndex());
                    outputMap.add(sourceMap);
                }
            }
        // }
        }
    }
    super.okPressed();
}
Also used : InputMappingData(org.talend.designer.webservice.data.InputMappingData) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PortNames(org.talend.designer.webservice.ws.wsdlinfo.PortNames) Function(org.talend.designer.webservice.ws.wsdlinfo.Function) WebServiceComponent(org.talend.designer.webservice.WebServiceComponent) Iterator(java.util.Iterator) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) OutPutMappingData(org.talend.designer.webservice.data.OutPutMappingData) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ParameterInfoUtil(org.talend.designer.webservice.ui.ParameterInfoUtil) HashMap(java.util.HashMap) Map(java.util.Map)

Example 90 with IMetadataColumn

use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.

the class BuildInDBStructure method createCurrentSchemaComposite.

/**
     * qzhang Comment method "createCurrentSchemaComposite".
     */
private void createCurrentSchemaComposite() {
    Composite curShemaComposite = new Composite(this, SWT.BORDER);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    gridLayout.marginBottom = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginLeft = 0;
    gridLayout.marginRight = 0;
    gridLayout.marginTop = 0;
    gridLayout.marginWidth = 0;
    gridLayout.verticalSpacing = 0;
    curShemaComposite.setLayout(gridLayout);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    curShemaComposite.setLayoutData(gridData);
    treeViewer = new TreeViewer(curShemaComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    treeViewer.setUseHashlookup(true);
    Tree tree = treeViewer.getTree();
    tree.setHeaderVisible(true);
    TreeColumn treeColumn = new TreeColumn(tree, SWT.LEFT);
    //$NON-NLS-1$
    treeColumn.setText(Messages.getString("BuildInDBStructure.CurrentSchema"));
    treeColumn.setWidth(300);
    SchemaTreePrivder schemaTreePrivder = new SchemaTreePrivder();
    treeViewer.setContentProvider(schemaTreePrivder);
    treeViewer.setLabelProvider(schemaTreePrivder);
    if (metadataTable == null) {
        metadataTable = new MetadataTable();
        metadataTable.setListColumns(new ArrayList<IMetadataColumn>());
    }
    SchemaTreeNode<SchemaTreeNode<IMetadataTable>> root = new SchemaTreeNode<SchemaTreeNode<IMetadataTable>>();
    schemaNode = new SchemaTreeNode<IMetadataTable>(schema);
    schemaNode.setParent(root);
    root.addChildren(schemaNode);
    if (metadataTable.getLabel() != null) {
        schemaNode.addChildren(metadataTable);
    }
    treeViewer.setInput(root);
    generateSelectAction = new GenerateSqlAction(treeViewer);
    addContextMenu();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) GridLayout(org.eclipse.swt.layout.GridLayout) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) Tree(org.eclipse.swt.widgets.Tree)

Aggregations

IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)149 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)82 ArrayList (java.util.ArrayList)73 List (java.util.List)34 IConnection (org.talend.core.model.process.IConnection)34 MetadataColumn (org.talend.core.model.metadata.MetadataColumn)31 HashMap (java.util.HashMap)30 IElementParameter (org.talend.core.model.process.IElementParameter)26 Map (java.util.Map)24 INode (org.talend.core.model.process.INode)24 MetadataTable (org.talend.core.model.metadata.MetadataTable)23 Node (org.talend.designer.core.ui.editor.nodes.Node)16 Point (org.eclipse.swt.graphics.Point)15 Connection (org.talend.designer.core.ui.editor.connections.Connection)10 INodeConnector (org.talend.core.model.process.INodeConnector)9 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)9 ChangeMetadataCommand (org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand)9 MetadataTableEditor (org.talend.core.ui.metadata.editor.MetadataTableEditor)8 IComponent (org.talend.core.model.components.IComponent)7 IODataComponent (org.talend.core.model.components.IODataComponent)7