Search in sources :

Example 61 with MetadataTable

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

the class RestResponseSchemaController method createComboCommand.

@Override
public Command createComboCommand(SelectionEvent event) {
    // Change the body type according to selected return body type
    Command changePropertyCommand = super.createComboCommand(event);
    Object newReturnType = null;
    if (changePropertyCommand != null) {
        newReturnType = ((PropertyChangeCommand) changePropertyCommand).getNewValue();
    }
    if (newReturnType == null) {
        return null;
    }
    // get old metadata column
    List<IMetadataTable> metadataList = ((INode) elem).getMetadataList();
    IMetadataTable oldMetadataTable = null;
    if (metadataList != null && metadataList.size() > 0) {
        oldMetadataTable = metadataList.get(0);
    } else {
        metadataList = new ArrayList<IMetadataTable>();
        ((INode) elem).setMetadataList(metadataList);
    }
    // create new metadata column
    IMetadataTable newMetadataTable = oldMetadataTable == null ? new MetadataTable() : oldMetadataTable.clone();
    List<IMetadataColumn> listColumns = newMetadataTable.getListColumns();
    if (listColumns == null) {
        listColumns = new ArrayList<IMetadataColumn>();
        newMetadataTable.setListColumns(listColumns);
    }
    IMetadataColumn bodyColumn = listColumns.size() > 0 ? listColumns.get(0) : new MetadataColumn();
    bodyColumn.setId("body");
    bodyColumn.setTalendType(newReturnType.toString());
    listColumns.clear();
    listColumns.add(bodyColumn);
    metadataList.clear();
    metadataList.add(newMetadataTable);
    // construct change metadata command
    ChangeMetadataCommand changeMetadataCommand = new ChangeMetadataCommand((INode) elem, null, oldMetadataTable, newMetadataTable);
    // construct compound command by combining above 2 commands
    CompoundCommand compoundCommand = new CompoundCommand();
    compoundCommand.add(changePropertyCommand);
    compoundCommand.add(changeMetadataCommand);
    return compoundCommand;
}
Also used : INode(org.talend.core.model.process.INode) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) ChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) ChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand)

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