Search in sources :

Example 91 with IMetadataColumn

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

the class InsertNewColumnCommand method creatMeatadataColumn.

private void creatMeatadataColumn(IMetadataColumn columnSource, String targetNodeName, AbstractNode sourceNode, IMetadataTable metadataTarget, int index) {
    IMetadataColumn createNewColumn = null;
    if (columnSource != null) {
        // dnd schema column
        createNewColumn = new MetadataColumn(columnSource);
        createNewColumn.setLabel(targetNodeName);
    } else {
        // dnd doc child
        createNewColumn = new MetadataColumn();
        createNewColumn.setLabel(targetNodeName);
        createNewColumn.setType(sourceNode.getType());
        createNewColumn.setTalendType(sourceNode.getType());
        if (sourceNode instanceof TreeNode) {
            createNewColumn.setKey(((TreeNode) sourceNode).isKey());
            createNewColumn.setNullable(((TreeNode) sourceNode).isNullable());
            createNewColumn.setPattern(((TreeNode) sourceNode).getPattern());
        }
    }
    if (index != -1) {
        metadataTarget.getListColumns().add(index, createNewColumn);
    } else {
        metadataTarget.getListColumns().add(createNewColumn);
    }
}
Also used : IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 92 with IMetadataColumn

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

the class InsertNewColumnCommand method getSourceColumn.

private IMetadataColumn getSourceColumn(String sourceTreeName, String sourceNodeName) {
    List<IODataComponent> inputs = manager.getMapperComponent().getIODataComponents().getInputs();
    IMetadataColumn columnSource = null;
    for (IODataComponent incoming : inputs) {
        if (sourceTreeName != null && sourceTreeName.equals(incoming.getConnection().getName())) {
            IMetadataTable metadataSource = incoming.getTable();
            for (IMetadataColumn column : metadataSource.getListColumns()) {
                if (column.getLabel().equals(sourceNodeName)) {
                    columnSource = column;
                    break;
                }
            }
            break;
        }
    }
    return columnSource;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IODataComponent(org.talend.core.model.components.IODataComponent) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 93 with IMetadataColumn

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

the class ProblemsAnalyserTest method prepareExternalData.

private ExternalMapperTable prepareExternalData(IMetadataTable table) {
    ExternalMapperTable externalMapperTable = new ExternalMapperTable();
    ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
    for (IMetadataColumn column : table.getListColumns()) {
        ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
        externalMapperTableEntry.setName(column.getLabel());
        externalMapperTableEntry.setType(column.getTalendType());
        externalMapperTableEntry.setNullable(column.isNullable());
        perTableEntries.add(externalMapperTableEntry);
    }
    externalMapperTable.setMetadataTableEntries(perTableEntries);
    return externalMapperTable;
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ArrayList(java.util.ArrayList) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 94 with IMetadataColumn

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

the class ScdComponent method metadataInputChanged.

@Override
public void metadataInputChanged(IODataComponent dataComponent, String connectionToApply) {
    List<ColumnNameChanged> columnNameList = dataComponent.getColumnNameChanged();
    if (columnNameList != null && columnNameList.size() > 0) {
        return;
    }
    // when delete columns,synchronization filed type
    IMetadataTable metadataTable = dataComponent.getTable();
    List<IMetadataColumn> listColumns = metadataTable.getListColumns();
    List<String> listNames = new ArrayList<String>();
    for (IMetadataColumn meta : listColumns) {
        listNames.add(meta.getLabel());
    }
    List<? extends IElementParameter> list = this.getElementParameters();
    // update sorcekeys
    IElementParameter param = getElementParameter(ScdParameterConstants.SOURCE_KEYS_PARAM_NAME);
    List<Map<String, String>> sorcevalues = (List<Map<String, String>>) param.getValue();
    updateFileds(listNames, list, sorcevalues, param, null);
    // update zero filed type
    IElementParameter useL0 = getElementParameter(ScdParameterConstants.USE_L0);
    if (useL0 != null && useL0.getValue().equals(Boolean.TRUE)) {
        IElementParameter l0FieldsParam = getElementParameter(ScdParameterConstants.L0_FIELDS_PARAM_NAME);
        List<Map<String, String>> values = (List<Map<String, String>>) l0FieldsParam.getValue();
        updateFileds(listNames, list, values, l0FieldsParam, useL0);
    }
    // update one filed type
    IElementParameter useL1 = getElementParameter(ScdParameterConstants.USE_L1);
    if (useL1 != null && useL1.getValue().equals(Boolean.TRUE)) {
        IElementParameter l1FieldsParam = getElementParameter(ScdParameterConstants.L1_FIELDS_PARAM_NAME);
        List<Map<String, String>> values = (List<Map<String, String>>) l1FieldsParam.getValue();
        updateFileds(listNames, list, values, l1FieldsParam, useL1);
    }
    // update two filed type
    IElementParameter useL2 = getElementParameter(ScdParameterConstants.USE_L2);
    if (useL2 != null && useL2.getValue().equals(Boolean.TRUE)) {
        IElementParameter l2FieldsParam = getElementParameter(ScdParameterConstants.L2_FIELDS_PARAM_NAME);
        List<Map<String, String>> values = (List<Map<String, String>>) l2FieldsParam.getValue();
        updateFileds(listNames, list, values, l2FieldsParam, useL2);
    }
    // update three filed type
    IElementParameter useL3 = getElementParameter(ScdParameterConstants.USE_L3);
    if (useL3 != null && useL3.getValue().equals(Boolean.TRUE)) {
        IElementParameter l3FieldsParam = getElementParameter(ScdParameterConstants.L3_FIELDS_PARAM_NAME);
        List<Map<String, String>> values = (List<Map<String, String>>) l3FieldsParam.getValue();
        updateFileds(listNames, list, values, l3FieldsParam, useL3);
    }
}
Also used : ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ColumnNameChanged(org.talend.core.model.metadata.ColumnNameChanged) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 95 with IMetadataColumn

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

the class ScdManager method getOutputColumns.

/**
     * DOC hcw Comment method "getOutputColumns".
     * 
     * @param node
     * @return
     */
public List<IMetadataColumn> getOutputColumns(INode node) {
    List<IMetadataTable> metaDataList = node.getMetadataList();
    List<IMetadataColumn> columns = new ArrayList<IMetadataColumn>();
    if (metaDataList != null) {
        for (IMetadataTable table : metaDataList) {
            columns.addAll(table.getListColumns());
        }
    }
    return columns;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

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