Search in sources :

Example 31 with MetadataColumn

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

the class MapperUI method prepareClosing.

public void prepareClosing(int response) {
    List<IMetadataTable> newMetadatas = new ArrayList<IMetadataTable>();
    EList<OutputXmlTree> outputTrees = null;
    if (response == SWT.OK || response == SWT.APPLICATION_MODAL) {
        // fix for bug TDI-18185
        mapperManager.fireCurrentDirectEditApply();
        // if press ok or apply , use copyOfMapData to check the metadata list
        outputTrees = copyOfMapData.getOutputTrees();
    } else {
        // if press cancel , use the original mapData
        outputTrees = ((XmlMapData) mapperComponent.getExternalEmfData()).getOutputTrees();
    }
    List<IMetadataTable> copyOfMetadata = new ArrayList<IMetadataTable>(mapperComponent.getMetadataList());
    for (OutputXmlTree outputTree : outputTrees) {
        IMetadataTable found = null;
        for (IMetadataTable table : mapperComponent.getMetadataList()) {
            if (outputTree.getName().equals(table.getTableName())) {
                found = table;
            }
        }
        if (found != null) {
            newMetadatas.add(found);
        } else {
            // create a new metadata if needed
            MetadataTable metadataTable = new MetadataTable();
            metadataTable.setTableName(outputTree.getName());
            mapperComponent.getProcess().addUniqueConnectionName(outputTree.getName());
            List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
            for (OutputTreeNode treeNode : outputTree.getNodes()) {
                MetadataColumn column = new MetadataColumn();
                column.setLabel(treeNode.getName());
                column.setKey(treeNode.isKey());
                column.setTalendType(treeNode.getType());
                column.setNullable(treeNode.isNullable());
                column.setPattern(treeNode.getPattern());
                listColumns.add(column);
            }
            metadataTable.setListColumns(listColumns);
            newMetadatas.add(metadataTable);
        }
    }
    mapperComponent.setMetadataList(newMetadatas);
    copyOfMetadata.removeAll(newMetadatas);
    List<IODataComponent> outputs = mapperComponent.getIODataComponents().getOuputs();
    List<String> connectionNames = new ArrayList<String>();
    for (IODataComponent output : outputs) {
        connectionNames.add(output.getUniqueName());
    }
    for (IMetadataTable leftTree : copyOfMetadata) {
        if (!connectionNames.contains(leftTree.getTableName())) {
            mapperComponent.getProcess().removeUniqueConnectionName(leftTree.getTableName());
        }
    }
}
Also used : ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) 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) MetadataTable(org.talend.core.model.metadata.MetadataTable) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) IODataComponent(org.talend.core.model.components.IODataComponent)

Example 32 with MetadataColumn

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

the class ChangeOutputConnectionOrderCommandTest method createMetadataTable.

private IMetadataTable createMetadataTable(String tableName) {
    IMetadataTable table = new MetadataTable();
    table.setTableName(tableName);
    MetadataColumn newColumn = new MetadataColumn();
    newColumn.setLabel("newColumn");
    newColumn.setTalendType("id_String");
    table.getListColumns().add(newColumn);
    return table;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable)

Example 33 with MetadataColumn

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

the class ConnectionCreateCommandTest method createSimpleMetadata2.

private IMetadataTable createSimpleMetadata2() {
    IMetadataTable table = new MetadataTable();
    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_Integer");
    table.getListColumns().add(column3);
    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) MetadataTable(org.talend.core.model.metadata.MetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 34 with MetadataColumn

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

the class MetadataEmfFactoryTest method createTestTable.

private IMetadataTable createTestTable() {
    IMetadataTable table = new MetadataTable();
    IMetadataColumn column = new MetadataColumn();
    //$NON-NLS-1$
    column.setLabel("C1");
    column.setTalendType(JavaTypesManager.INTEGER.getId());
    table.getListColumns().add(column);
    column = new MetadataColumn();
    //$NON-NLS-1$
    column.setLabel("C2");
    column.setTalendType(JavaTypesManager.STRING.getId());
    table.getListColumns().add(column);
    column = new MetadataColumn();
    //$NON-NLS-1$
    column.setLabel("C3");
    column.setTalendType(JavaTypesManager.STRING.getId());
    table.getListColumns().add(column);
    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) MetadataTable(org.talend.core.model.metadata.MetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 35 with MetadataColumn

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

the class ConnectionCreateCommandTest method createSimpleMetadata1.

private IMetadataTable createSimpleMetadata1() {
    IMetadataTable table = new 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_Integer");
    table.getListColumns().add(column3);
    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) MetadataTable(org.talend.core.model.metadata.MetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Aggregations

MetadataColumn (org.talend.core.model.metadata.MetadataColumn)44 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)35 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)20 ArrayList (java.util.ArrayList)14 MetadataTable (org.talend.core.model.metadata.MetadataTable)13 Test (org.junit.Test)6 MetadataColumnExt (org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt)6 IElementParameter (org.talend.core.model.process.IElementParameter)4 Node (org.talend.designer.core.ui.editor.nodes.Node)4 IComponent (org.talend.core.model.components.IComponent)3 IConnection (org.talend.core.model.process.IConnection)3 ChangeMetadataCommand (org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand)3 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)3 List (java.util.List)2 Schema (org.apache.avro.Schema)2 Command (org.eclipse.gef.commands.Command)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)2 DisposeListener (org.eclipse.swt.events.DisposeListener)2 Point (org.eclipse.swt.graphics.Point)2