Search in sources :

Example 31 with MetadataTable

use of org.talend.core.model.metadata.MetadataTable 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 32 with MetadataTable

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

the class PostgresGenerationManagerTest method getMetadataTable.

private MetadataTable getMetadataTable(String[] entitiesName) {
    MetadataTable table = new MetadataTable();
    for (String element : entitiesName) {
        MetadataColumn column = new MetadataColumn();
        column.setLabel(element);
        table.getListColumns().add(column);
    }
    return table;
}
Also used : IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable)

Example 33 with MetadataTable

use of org.talend.core.model.metadata.MetadataTable 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 34 with MetadataTable

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

the class WebServiceHelper method getWebServiceUI.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.repository.ui.wizards.metadata.connection.wsdl.IWebService#getWebServiceUI(org.eclipse.swt.widgets
     * .Composite, org.talend.core.model.components.IComponent)
     */
@Override
public AbstractWebService getWebServiceUI(Composite uiParent, ConnectionItem connectionItem) {
    // TODO Auto-generated method stub
    WebServiceComponent wenCom = new WebServiceComponent();
    wenCom.initialize();
    IComponent iComponent = ComponentsFactoryProvider.getInstance().get("tWebService", ComponentCategory.CATEGORY_4_DI.getName());
    List<? extends IElementParameter> parameters = iComponent.createElementParameters(wenCom);
    wenCom.setElementParameters(parameters);
    if (connectionItem.getState() != null) {
        WSDLSchemaConnection connection = (WSDLSchemaConnection) connectionItem.getConnection();
        wenCom.getElementParameter("ENDPOINT").setValue(connection.getEndpointURI());
        String currentURL = connection.getWSDL();
        String method = connection.getMethodName();
        String currePortName = connection.getPortName();
        String nameSpace = connection.getServerNameSpace();
        String serverName = connection.getServerName();
        String portNameSpace = connection.getPortNameSpace();
        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);
        }
        //
        if (method != null) {
            IElementParameter METHODPara = wenCom.getElementParameter("METHOD");
            METHODPara.setValue(method);
        }
        if (nameSpace != null) {
            IElementParameter Service_NS = wenCom.getElementParameter("SERVICE_NS");
            Service_NS.setValue(nameSpace);
        }
        if (serverName != null) {
            IElementParameter Service_Name = wenCom.getElementParameter("SERVICE_NAME");
            Service_Name.setValue(serverName);
        }
        if (portNameSpace != null) {
            IElementParameter Port_NS = wenCom.getElementParameter("PORT_NS");
            Port_NS.setValue(portNameSpace);
        }
        if (connection.getParameterValue() != null) {
            IElementParameter INPUT_PARAMSPara = wenCom.getElementParameter("INPUT_PARAMS");
            List<Map<String, String>> inputparaValue = (List<Map<String, String>>) INPUT_PARAMSPara.getValue();
            EList inputList = connection.getParameterValue();
            for (int i = 0; i < inputList.size(); i++) {
                Map<String, String> inputMap = new HashMap<String, String>(2);
                WSDLParameter parameter = (WSDLParameter) inputList.get(i);
                if (parameter.getElement() != null) {
                    if (parameter.getExpression() != null) {
                        inputMap.put("EXPRESSION", parameter.getExpression());
                    }
                    inputMap.put("ELEMENT", parameter.getElement());
                    inputparaValue.add(inputMap);
                }
                if (parameter.getSource() != null) {
                    inputMap.put("SOURCE", parameter.getSource());
                    inputparaValue.add(inputMap);
                }
                if (parameter.getColumn() != null) {
                    inputMap.put("COLUMN", parameter.getColumn());
                    inputparaValue.add(inputMap);
                }
                if (parameter.getParameterInfo() != null) {
                    inputMap.put("PARAMETERINFO", parameter.getParameterInfo());
                    inputMap.put("PARAPARENT", parameter.getParameterInfoParent());
                    inputparaValue.add(inputMap);
                }
            }
        }
        if (connection.getOutputParameter() != null) {
            IElementParameter OUTPUT_PARAMSPara = wenCom.getElementParameter("OUTPUT_PARAMS");
            List<Map<String, String>> outputMap = (List<Map<String, String>>) OUTPUT_PARAMSPara.getValue();
            EList inputList = connection.getOutputParameter();
            for (int i = 0; i < inputList.size(); i++) {
                Map<String, String> eleMap = new HashMap<String, String>(3);
                WSDLParameter parameter = (WSDLParameter) inputList.get(i);
                if (parameter.getExpression() != null || parameter.getColumn() != null) {
                    if (parameter.getExpression() != null) {
                        eleMap.put("EXPRESSION", parameter.getExpression());
                    }
                    // if (parameter.getColumn() != null) {
                    eleMap.put("COLUMN", parameter.getColumn());
                    // }
                    outputMap.add(eleMap);
                }
                if (parameter.getElement() != null) {
                    eleMap.put("ELEMENT", parameter.getElement());
                    outputMap.add(eleMap);
                }
                if (parameter.getSource() != null) {
                    eleMap.put("SOURCE", parameter.getSource());
                    outputMap.add(eleMap);
                }
                if (parameter.getParameterInfo() != null) {
                    eleMap.put("PARAMETERINFO", parameter.getParameterInfo());
                    eleMap.put("PARAPARENT", parameter.getParameterInfoParent());
                    outputMap.add(eleMap);
                }
            }
        }
    }
    MetadataTable inputMetadata = new MetadataTable();
    inputMetadata.setAttachedConnector("FLOW");
    inputMetadata.setLabel("Input");
    MetadataTable outputMetadaTable = null;
    List<org.talend.core.model.metadata.IMetadataColumn> newColumnList = new ArrayList<org.talend.core.model.metadata.IMetadataColumn>();
    List<org.talend.core.model.metadata.IMetadataColumn> newInputColumnList = new ArrayList<org.talend.core.model.metadata.IMetadataColumn>();
    if (connectionItem.getState() != null) {
        outputMetadaTable = new MetadataTable();
        outputMetadaTable.setAttachedConnector("OUTPUT");
        outputMetadaTable.setLabel("Output");
        WSDLSchemaConnection connection = (WSDLSchemaConnection) connectionItem.getConnection();
        Set<org.talend.core.model.metadata.builder.connection.MetadataTable> tables = ConnectionHelper.getTables(connection);
        //
        // EList<MetadataColumn> schemaMetadataColumn =
        // ((org.talend.core.model.metadata.builder.connection.MetadataTable) ConnectionHelper
        // .getTables(connection).toArray()[0]).getColumns();
        Iterator it = tables.iterator();
        while (it.hasNext()) {
            org.talend.core.model.metadata.builder.connection.MetadataTable metadatatable = (org.talend.core.model.metadata.builder.connection.MetadataTable) it.next();
            if (metadatatable.getLabel().equals("Output")) {
                for (int i = 0; i < metadatatable.getColumns().size(); i++) {
                    org.talend.core.model.metadata.builder.connection.MetadataColumn col = metadatatable.getColumns().get(i);
                    org.talend.core.model.metadata.MetadataColumn newColumn = new org.talend.core.model.metadata.MetadataColumn();
                    newColumn.setLabel(col.getLabel());
                    newColumn.setTalendType(col.getTalendType());
                    newColumn.setOriginalDbColumnName(col.getLabel());
                    newColumnList.add(newColumn);
                }
                outputMetadaTable.setListColumns(newColumnList);
            } else {
                // .getTables(connection).toArray()[1]).getColumns();
                for (int i = 0; i < metadatatable.getColumns().size(); i++) {
                    org.talend.core.model.metadata.builder.connection.MetadataColumn col = metadatatable.getColumns().get(i);
                    org.talend.core.model.metadata.MetadataColumn newColumn = new org.talend.core.model.metadata.MetadataColumn();
                    newColumn.setLabel(col.getLabel());
                    newColumn.setTalendType(col.getTalendType());
                    newColumn.setOriginalDbColumnName(col.getLabel());
                    newInputColumnList.add(newColumn);
                }
                inputMetadata.setListColumns(newInputColumnList);
            }
        }
    } else {
        outputMetadaTable = new MetadataTable();
        outputMetadaTable.setAttachedConnector("OUTPUT");
    }
    List<IMetadataTable> metadataTableList = new ArrayList<IMetadataTable>(4);
    metadataTableList.add(inputMetadata);
    metadataTableList.add(outputMetadaTable);
    wenCom.setMetadataList(metadataTableList);
    WebServiceComponentMain b = new WebServiceComponentMain(wenCom);
    wenCom.setComponent(b.getWebServiceComponent().getComponent());
    webServiceUI = new WebServiceUI(uiParent, b, connectionItem);
    webServiceUI.init();
    manager.addWebServiceSaveListener(this);
    return webServiceUI;
}
Also used : HashMap(java.util.HashMap) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) WebServiceComponent(org.talend.designer.webservice.WebServiceComponent) WebServiceComponentMain(org.talend.designer.webservice.WebServiceComponentMain) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) Iterator(java.util.Iterator) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List) WSDLSchemaConnection(org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) EList(org.eclipse.emf.common.util.EList) WSDLParameter(org.talend.core.model.metadata.builder.connection.WSDLParameter) HashMap(java.util.HashMap) Map(java.util.Map)

Example 35 with MetadataTable

use of org.talend.core.model.metadata.MetadataTable 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

MetadataTable (org.talend.core.model.metadata.MetadataTable)61 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)46 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)29 ArrayList (java.util.ArrayList)23 HashMap (java.util.HashMap)15 Map (java.util.Map)14 IElementParameter (org.talend.core.model.process.IElementParameter)14 Item (org.talend.core.model.properties.Item)14 MetadataColumn (org.talend.core.model.metadata.MetadataColumn)13 IConnection (org.talend.core.model.process.IConnection)13 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 Node (org.talend.designer.core.ui.editor.nodes.Node)11 List (java.util.List)9 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)9 Command (org.eclipse.gef.commands.Command)8 Point (org.eclipse.swt.graphics.Point)8 INode (org.talend.core.model.process.INode)8 ChangeMetadataCommand (org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand)8 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)8 Connection (org.talend.designer.core.ui.editor.connections.Connection)8