Search in sources :

Example 36 with IMetadataTable

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

the class MetadataEmfFacotryTest method testSetMetadataTable.

@Test
public void testSetMetadataTable() {
    IMetadataTable table = new MetadataTable();
    table.getAdditionalProperties().put(SAPBWTableHelper.SAP_INFOOBJECT_INNER_TYPE, SAPBWTableHelper.IO_INNERTYPE_ATTRIBUTE);
    MetadataEmfFactory factory = new MetadataEmfFactory();
    factory.setMetadataTable(table);
    Object innerType = factory.getMetadataType().getAdditionalProperties().get(SAPBWTableHelper.SAP_INFOOBJECT_INNER_TYPE);
    assertEquals(SAPBWTableHelper.IO_INNERTYPE_ATTRIBUTE, innerType);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataEmfFactory(org.talend.designer.core.model.metadata.MetadataEmfFactory) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) Test(org.junit.Test)

Example 37 with IMetadataTable

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

the class NodeQueryCheckUtilTest method createSimpleMetadata.

private IMetadataTable createSimpleMetadata() {
    IMetadataTable table = new org.talend.core.model.metadata.MetadataTable();
    IMetadataColumn column1 = new MetadataColumn();
    //$NON-NLS-1$
    column1.setLabel("C1");
    //$NON-NLS-1$
    column1.setTalendType("id_String");
    table.getListColumns().add(column1);
    IMetadataColumn column2 = new MetadataColumn();
    //$NON-NLS-1$
    column2.setLabel("C2");
    //$NON-NLS-1$
    column2.setTalendType("id_String");
    table.getListColumns().add(column2);
    IMetadataColumn column3 = new MetadataColumn();
    //$NON-NLS-1$
    column3.setLabel("C3");
    //$NON-NLS-1$
    column3.setTalendType("id_String");
    table.getListColumns().add(column3);
    IMetadataColumn column4 = new MetadataColumn();
    //$NON-NLS-1$
    column4.setLabel("C4");
    //$NON-NLS-1$
    column4.setTalendType("id_String");
    table.getListColumns().add(column4);
    return table;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 38 with IMetadataTable

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

the class PostgresGenerationManagerTest method init.

private void init(String schema, String main_table, String lookup_table) {
    List<IConnection> incomingConnections = new ArrayList<IConnection>();
    String[] mainTableEntities = new String[] { "id", "name", "classNum" };
    String[] lookupEndtities = new String[] { "id", "score" };
    incomingConnections.add(mockConnection(schema, main_table, mainTableEntities));
    incomingConnections.add(mockConnection(schema, lookup_table, lookupEndtities));
    component.setIncomingConnections(incomingConnections);
    ExternalDbMapData externalData = new ExternalDbMapData();
    List<ExternalDbMapTable> inputs = new ArrayList<ExternalDbMapTable>();
    List<ExternalDbMapTable> outputs = new ArrayList<ExternalDbMapTable>();
    // main table
    ExternalDbMapTable inputTable = new ExternalDbMapTable();
    inputTable.setTableName(schema + "." + main_table);
    List<ExternalDbMapEntry> entities = getMetadataEntities(mainTableEntities, new String[3]);
    inputTable.setMetadataTableEntries(entities);
    inputs.add(inputTable);
    // lookup table
    inputTable = new ExternalDbMapTable();
    inputTable.setTableName(schema + "." + lookup_table);
    entities = getMetadataEntities(lookupEndtities, new String[2]);
    inputTable.setMetadataTableEntries(entities);
    inputs.add(inputTable);
    // output
    ExternalDbMapTable outputTable = new ExternalDbMapTable();
    outputTable.setName("grade");
    List<ExternalDbMapEntry> conditions = new ArrayList<ExternalDbMapEntry>();
    conditions.add(new ExternalDbMapEntry(schema + "." + main_table + ".id =3"));
    outputTable.setCustomWhereConditionsEntries(conditions);
    String[] names = new String[] { "id", "name", "classNum", "score" };
    String[] expressions = new String[] { schema + "." + main_table + ".id", schema + "." + main_table + ".name", schema + "." + main_table + ".classNum", schema + "." + lookup_table + ".score" };
    outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
    outputs.add(outputTable);
    externalData.setInputTables(inputs);
    externalData.setOutputTables(outputs);
    component.setExternalData(externalData);
    List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
    MetadataTable metadataTable = getMetadataTable(names);
    metadataTable.setLabel("grade");
    metadataList.add(metadataTable);
    component.setMetadataList(metadataList);
    Process process = mock(Process.class);
    when(process.getContextManager()).thenReturn(new JobContextManager());
    component.setProcess(process);
}
Also used : ExternalDbMapData(org.talend.designer.dbmap.external.data.ExternalDbMapData) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) Process(org.talend.designer.core.ui.editor.process.Process) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ExternalDbMapTable(org.talend.designer.dbmap.external.data.ExternalDbMapTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) JobContextManager(org.talend.core.model.context.JobContextManager) ExternalDbMapEntry(org.talend.designer.dbmap.external.data.ExternalDbMapEntry)

Example 39 with IMetadataTable

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

the class MultiUIManager method autoMap.

/**
     * 
     * DOC wzhang Comment method "autoMap". for multiSchema.
     */
public void autoMap() {
    List<FOXTreeNode> treeData = foxManager.getTreeData(foxManager.getCurrentSchema());
    if (treeData == null || treeData.size() < 1) {
        return;
    }
    FOXTreeNode root = treeData.get(0);
    List<FOXTreeNode> mappableNodes = new ArrayList<FOXTreeNode>();
    getMappableNode((Element) root, mappableNodes);
    IConnection connection = foxUI.getConnection();
    if (connection != null) {
        IMetadataTable metadataTable = connection.getMetadataTable();
        if (metadataTable != null) {
            List<IMetadataColumn> schemaData = metadataTable.getListColumns();
            for (FOXTreeNode node : mappableNodes) {
                for (IMetadataColumn column : schemaData) {
                    if (node.getLabel().equals(column.getLabel())) {
                        node.setTable(metadataTable);
                        node.setColumn(column);
                        node.setDefaultValue(null);
                        node.setRow(foxManager.getCurrentSchema());
                        break;
                    }
                }
            }
        }
    }
    this.foxUI.refreshXMLViewer(root);
    this.foxUI.redrawLinkers();
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 40 with IMetadataTable

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

the class MultiFOXManager method initModel.

public void initModel() {
    int i = 0;
    List<? extends IConnection> incomingConnections = NodeUtil.getIncomingConnections(foxComponent, IConnectionCategory.FLOW);
    for (IConnection connection : incomingConnections) {
        IMetadataTable metadataTable = connection.getMetadataTable();
        metadataTable.setLabel(connection.getUniqueName());
        treeData = new ArrayList<FOXTreeNode>();
        if (// the first schema as current
        i == 0)
            currentSchema = metadataTable.getLabel();
        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;
        //$NON-NLS-1$
        String schemaId = metadataTable.getLabel() + ":";
        // build root tree
        List<Map<String, String>> rootTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.ROOT);
        if (rootTable != null) {
            for (Map<String, String> rootMap : rootTable) {
                String newPath = rootMap.get(FileOutputXMLComponent.PATH);
                String columnName = rootMap.get(FileOutputXMLComponent.COLUMN);
                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();
                }
                //$NON-NLS-1$
                String flag = columnName + ":";
                if (columnName != null && columnName.length() > 0 && !flag.startsWith(metadataTable.getLabel() + ":")) {
                    //$NON-NLS-1$
                    continue;
                }
                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 = 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);
                }
                temp.setRow(metadataTable.getLabel());
                if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
                    //$NON-NLS-1$
                    columnName = columnName.replace(schemaId, "");
                    temp.setColumn(metadataTable.getColumn(columnName));
                    temp.setTable(metadataTable);
                }
            }
        }
        // build group tree
        current = mainNode;
        currentPath = mainPath;
        boolean isFirst = true;
        List<Map<String, String>> groupTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.GROUP);
        if (groupTable != null) {
            for (Map<String, String> groupMap : groupTable) {
                String newPath = groupMap.get(FileOutputXMLComponent.PATH);
                String columnName = groupMap.get(FileOutputXMLComponent.COLUMN);
                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();
                }
                //$NON-NLS-1$
                String flag = columnName + ":";
                if (columnName != null && columnName.length() > 0 && !flag.startsWith(metadataTable.getLabel() + ":")) {
                    //$NON-NLS-1$
                    continue;
                }
                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);
                }
                temp.setRow(metadataTable.getLabel());
                if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
                    //$NON-NLS-1$
                    columnName = columnName.replace(schemaId, "");
                    temp.setColumn(metadataTable.getColumn(columnName));
                    temp.setTable(metadataTable);
                }
            }
        }
        // build loop tree
        current = mainNode;
        currentPath = mainPath;
        isFirst = true;
        List<Map<String, String>> loopTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.LOOP);
        if (loopTable != null) {
            for (Map<String, String> loopMap : loopTable) {
                String newPath = loopMap.get(FileOutputXMLComponent.PATH);
                String columnName = loopMap.get(FileOutputXMLComponent.COLUMN);
                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();
                }
                //$NON-NLS-1$
                String flag = columnName + ":";
                if (columnName != null && columnName.length() > 0 && !flag.startsWith(metadataTable.getLabel() + ":")) {
                    //$NON-NLS-1$
                    continue;
                }
                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 (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);
                }
                temp.setRow(metadataTable.getLabel());
                if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
                    //$NON-NLS-1$
                    columnName = columnName.replace(schemaId, "");
                    temp.setColumn(metadataTable.getColumn(columnName));
                    temp.setTable(metadataTable);
                }
            }
            if (rootNode == null) {
                //$NON-NLS-1$
                rootNode = new Element("rootTag");
            }
            rootNode.setParent(null);
            if (haveOrder) {
                orderNode(rootNode);
            }
            treeData.add(rootNode);
            rootNode.setRow(metadataTable.getLabel());
            contents.put(metadataTable.getLabel(), treeData);
            i++;
        }
    }
}
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) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

IMetadataTable (org.talend.core.model.metadata.IMetadataTable)212 ArrayList (java.util.ArrayList)102 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)81 IElementParameter (org.talend.core.model.process.IElementParameter)67 IConnection (org.talend.core.model.process.IConnection)66 List (java.util.List)56 INode (org.talend.core.model.process.INode)54 Node (org.talend.designer.core.ui.editor.nodes.Node)50 HashMap (java.util.HashMap)48 Map (java.util.Map)39 MetadataTable (org.talend.core.model.metadata.MetadataTable)34 INodeConnector (org.talend.core.model.process.INodeConnector)32 Connection (org.talend.designer.core.ui.editor.connections.Connection)28 Process (org.talend.designer.core.ui.editor.process.Process)25 IComponent (org.talend.core.model.components.IComponent)22 ConnectionItem (org.talend.core.model.properties.ConnectionItem)20 MetadataColumn (org.talend.core.model.metadata.MetadataColumn)18 ChangeMetadataCommand (org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand)17 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)16 Point (org.eclipse.swt.graphics.Point)15