Search in sources :

Example 1 with MetadataTable

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

the class MapperManager method addOutput.

/**
     * DOC amaumont Comment method "addOutput".
     */
public void addOutput() {
    String tableName = uiManager.openNewOutputCreationDialog();
    if (tableName == null) {
        return;
    }
    IProcess process = mapperComponent.getProcess();
    //$NON-NLS-1$
    String uniqueName = process.generateUniqueConnectionName("table");
    process.addUniqueConnectionName(uniqueName);
    MetadataTable metadataTable = new MetadataTable();
    metadataTable.setTableName(uniqueName);
    // metadataTable.setId(uniqueName);
    metadataTable.setLabel(tableName);
    List<DataMapTableView> outputsTablesView = getUiManager().getOutputsTablesView();
    int sizeOutputsView = outputsTablesView.size();
    Control lastChild = null;
    if (sizeOutputsView - 1 >= 0) {
        lastChild = outputsTablesView.get(sizeOutputsView - 1);
    }
    IDataMapTable abstractDataMapTable = new OutputTable(this, metadataTable, uniqueName, tableName);
    TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
    DataMapTableView dataMapTableView = uiManager.createNewOutputTableView(lastChild, abstractDataMapTable, tablesZoneViewOutputs);
    tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    tablesZoneViewOutputs.layout();
    uiManager.moveOutputScrollBarZoneToMax();
    uiManager.refreshBackground(true, false);
    tablesZoneViewOutputs.layout();
    uiManager.selectDataMapTableView(dataMapTableView, true, false);
}
Also used : Control(org.eclipse.swt.widgets.Control) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) InputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) TablesZoneView(org.talend.designer.dbmap.ui.visualmap.zone.scrollable.TablesZoneView) IProcess(org.talend.core.model.process.IProcess) OutputTable(org.talend.designer.dbmap.model.table.OutputTable)

Example 2 with MetadataTable

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

the class ChangeMultiSchemasCommand method addSchemasMap.

private void addSchemasMap(List<Map<String, String>> newValueList, List<IMetadataTable> newTables, SchemasKeyData keyData) {
    if (keyData == null) {
        return;
    }
    if (keyData.getParent() != null) {
        // not root
        //
        Map<String, String> map = new HashMap<String, String>();
        final String uniqueRecord = keyData.getUniqueRecord();
        final String recordType = keyData.getRecordType();
        map.put(IMultiSchemaConstant.SCHEMA, uniqueRecord);
        map.put(IMultiSchemaConstant.RECORD, TalendTextUtils.addQuotes(recordType));
        map.put(IMultiSchemaConstant.PARENT_RECORD, TalendTextUtils.addQuotes(keyData.getParent().getRecordType()));
        map.put(IMultiSchemaConstant.CARDINALITY, keyData.getCard());
        map.put(IMultiSchemaConstant.FIELDDELIMITED, TalendTextUtils.addQuotes(keyData.getSeparator()));
        newValueList.add(map);
        //
        String connectionBaseName = MetadataToolHelper.validateColumnName(MultiSchemasUtil.getConnectionBaseName(uniqueRecord), 0);
        String uniqueConnName = node.getProcess().generateUniqueConnectionName(connectionBaseName);
        MetadataTable table = new MetadataTable();
        table.setLabel(uniqueRecord);
        table.setTableName(uniqueConnName);
        //$NON-NLS-1$
        String keyIndex = "";
        boolean first = true;
        List<MultiMetadataColumn> metadataColumnsInModel = keyData.getMetadataColumnsInModel();
        for (int i = 0; i < metadataColumnsInModel.size(); i++) {
            MultiMetadataColumn column = metadataColumnsInModel.get(i);
            table.getListColumns().add(column.clone(true));
            if (column.isKey()) {
                if (first) {
                    keyIndex += i;
                } else {
                    //$NON-NLS-1$
                    keyIndex += "," + i;
                }
                first = false;
            }
        }
        map.put(IMultiSchemaConstant.KEY_COLUMN_INDEX, TalendTextUtils.addQuotes(keyIndex));
        newTables.add(table);
    }
    for (SchemasKeyData child : keyData.getChildren()) {
        addSchemasMap(newValueList, newTables, child);
    }
}
Also used : HashMap(java.util.HashMap) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData) MultiMetadataColumn(org.talend.designer.filemultischemas.data.MultiMetadataColumn)

Example 3 with MetadataTable

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

the class UIManager method getCurrentColumnData.

/**
     * ftang Comment method "saveAllData".
     */
private List<Map<String, Object>> getCurrentColumnData() {
    List<Map<String, Object>> map = new ArrayList<Map<String, Object>>();
    MetadataTable table = (MetadataTable) rgManager.getRowGeneratorComponent().getMetadataList().get(0);
    convert(rgManager.getRowGeneratorComponent(), table, generatorUI.getFunctionManager());
    for (IMetadataColumn col : table.getListColumns()) {
        MetadataColumnExt ext = (MetadataColumnExt) col;
        Map<String, Object> value = new HashMap<String, Object>();
        value.put(RowGeneratorComponent.COLUMN_NAME, ext.getLabel());
        value.put(RowGeneratorComponent.ARRAY, FunctionManagerExt.getOneColData(ext));
        map.add(value);
    }
    return map;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) HashMap(java.util.HashMap) Map(java.util.Map) MetadataColumnExt(org.talend.designer.rowgenerator.ui.editor.MetadataColumnExt)

Example 4 with MetadataTable

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

the class UIManager method closeRowGenerator.

/**
     * yzhang Comment method "closeRowGenerator".
     * 
     * @param response
     */
public void closeRowGenerator(int response, boolean fromDialog) {
    setRowGenResponse(response);
    Composite parent = generatorUI.getRowGenUIParent();
    saveCurrentUIProperties();
    MetadataTable table = (MetadataTable) rgManager.getRowGeneratorComponent().getMetadataList().get(0);
    boolean hasColumns = (table != null) && (table.getListColumns() != null && (table.getListColumns().size() != 0));
    List<Map<String, Object>> originalColumnDataList = this.getRowGenManager().getRowGeneratorComponent().getMapList();
    List<Map<String, Object>> currentColumnDataList = getCurrentColumnData();
    boolean containsAll1 = originalColumnDataList.containsAll(currentColumnDataList);
    boolean containsAll2 = currentColumnDataList.containsAll(originalColumnDataList);
    boolean containsAll = containsAll1 && containsAll2;
    if (hasColumns && !containsAll && response == SWT.CANCEL) {
        boolean isNotSaveSetting = MessageDialog.openQuestion(parent.getShell(), Messages.getString("UIManager.MessageBox.title"), //$NON-NLS-1$ //$NON-NLS-2$
        Messages.getString("UIManager.MessageBox.Content"));
        if (!isNotSaveSetting) {
            response = SWT.NONE;
            setRowGenResponse(response);
        }
        return;
    }
    if (response == SWT.OK) {
        saveAllData(currentColumnDataList);
    }
    if (parent instanceof Shell && !fromDialog) {
        ((Shell) parent).close();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Composite(org.eclipse.swt.widgets.Composite) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with MetadataTable

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

the class RowGeneratorComponent method reinitColumnValues.

public void reinitColumnValues(List<Map<String, Object>> map) {
    MetadataTable tableExt = (MetadataTable) this.getMetadataList().get(0);
    List<String> columnNames = new ArrayList<String>();
    for (IMetadataColumn column : tableExt.getListColumns()) {
        columnNames.add(column.getLabel());
    }
    if (map.size() > tableExt.getListColumns().size()) {
        for (int i = 0; i < map.size(); i++) {
            Map<String, Object> line = map.get(i);
            if (!columnNames.contains(line.get(COLUMN_NAME))) {
                map.remove(line);
            }
        }
    }
}
Also used : 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)

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