Search in sources :

Example 6 with IMetadataColumn

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

the class MetadataSchemaExt method initializeOneColumn.

@Override
@SuppressWarnings("unchecked")
protected IMetadataColumn initializeOneColumn(final IMetadataColumn metadataColumn, final NamedNodeMap nodeMap) {
    IMetadataColumn column = super.initializeOneColumn(metadataColumn, nodeMap);
    MetadataColumnExt columnExt = new MetadataColumnExt((MetadataColumn) column);
    //$NON-NLS-1$
    Node function = nodeMap.getNamedItem("function");
    if (function != null) {
        //$NON-NLS-1$
        Node parameter = nodeMap.getNamedItem("parameter");
        //$NON-NLS-1$
        Node preview = nodeMap.getNamedItem("preview");
        Function function2 = funManager.getCurrentFunction(function.getNodeValue(), columnExt);
        List<Parameter> parms = function2.getParameters();
        //$NON-NLS-1$
        String[] paraStr = parameter.getNodeValue().split(";");
        for (String string : paraStr) {
            //$NON-NLS-1$
            String[] nv = string.split("=>");
            for (Parameter para : parms) {
                if (para.getName().equals(nv[0].trim())) {
                    para.setValue(nv[1]);
                    break;
                }
            }
        }
        columnExt.setFunction(function2);
        columnExt.setPreview(preview.getNodeValue());
    } else {
        Function function2 = funManager.getDefaultFunction(columnExt, columnExt.getTalendType());
        columnExt.setFunction(function2);
        //$NON-NLS-1$
        columnExt.setPreview("");
    }
    return columnExt;
}
Also used : Function(org.talend.designer.rowgenerator.data.Function) Node(org.w3c.dom.Node) Parameter(org.talend.designer.rowgenerator.data.Parameter) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 7 with IMetadataColumn

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

the class RowGenProcessMain method initPerlArray.

/**
     * qzhang Comment method "initPerlArray".
     */
private void initPerlArray() {
    List<Map<String, Object>> map = new ArrayList<Map<String, Object>>();
    MetadataTable table = (MetadataTable) this.component.getMetadataList().get(0);
    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);
    }
    this.component.setTableElementParameter(map);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) 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 8 with IMetadataColumn

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

the class RowGeneratorUI method createSchemaComposite.

/**
     * qzhang Comment method "createSchemaComposite".
     */
private void createSchemaComposite() {
    outputMetaTable = externalNode.getMetadataList().get(0);
    uiManager.convert(externalNode, outputMetaTable, functionManager);
    //$NON-NLS-1$
    metadataTableEditor = new MetadataTableEditorExt(outputMetaTable, "", this.functionManager);
    metadataTableEditor.setRowGenUI(this);
    inputReadOnly = this.externalNode.getProcess().isReadOnly();
    if (this.externalNode.getOriginalNode().getJobletNode() != null) {
        inputReadOnly = this.externalNode.getOriginalNode().isReadOnly();
    } else if (this.externalNode.getOriginalNode().getJunitNode() != null) {
        inputReadOnly = true;
    }
    dataTableView = new MetadataTableEditorViewExt(datasFlowViewSashForm, SWT.BORDER, metadataTableEditor, inputReadOnly, !inputReadOnly, externalNode, functionManager);
    dataTableView.getExtendedTableViewer().setCommandStack(generatorManager.getCommandStack());
    dataTableView.setGeneratorUI(this);
    dataTableView.setShowDbTypeColumn(true, true, false);
    dataTableView.setShowDbColumnName(false, false);
    metadataTableEditor.setModifiedBeanListenable(dataTableView.getTableViewerCreator());
    // see bug 7471,record the modification of the column value.
    metadataTableEditor.addModifiedBeanListener(new IModifiedBeanListener<IMetadataColumn>() {

        @Override
        public void handleEvent(ModifiedBeanEvent<IMetadataColumn> event) {
            if (AbstractMetadataTableEditorView.ID_COLUMN_NAME.equals(event.column.getId())) {
                IMetadataColumn modifiedObject = event.bean;
                if (modifiedObject != null) {
                    String originalLabel = changedNameColumns.get(modifiedObject);
                    if (originalLabel == null) {
                        changedNameColumns.put(modifiedObject.getLabel(), (String) event.previousValue);
                    }
                }
            }
        }
    });
    // resize all the columns but not the table
    for (int i = 0; i < dataTableView.getTable().getColumnCount(); i++) {
        dataTableView.getTable().getColumn(i).pack();
    }
    dataTableView.getTable().getColumn(0).setWidth(0);
}
Also used : MetadataTableEditorExt(org.talend.designer.rowgenerator.ui.editor.MetadataTableEditorExt) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataTableEditorViewExt(org.talend.designer.rowgenerator.ui.editor.MetadataTableEditorViewExt)

Example 9 with IMetadataColumn

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

the class MetadataExtPasteCommand method createPastableBeansList.

@Override
public List createPastableBeansList(ExtendedTableModel extendedTable, List copiedObjectsList) {
    ArrayList list = new ArrayList();
    ArrayList countList = new ArrayList();
    ArrayList<String> labelsExisted = getLabelsExisted(extendedTable);
    for (Object current : copiedObjectsList) {
        if (current instanceof IMetadataColumn) {
            IMetadataColumn copy = ((IMetadataColumn) current).clone();
            String nextGeneratedColumnName = ((MetadataTableEditor) extendedTable).getNextGeneratedColumnName(copy.getLabel());
            if (labelsExisted.contains(nextGeneratedColumnName)) {
                nextGeneratedColumnName = validateColumnName(nextGeneratedColumnName, labelsExisted);
            }
            labelsExisted.add(nextGeneratedColumnName);
            copy.setLabel(nextGeneratedColumnName);
            if (copy instanceof MetadataColumnExt) {
                list.add(copy);
            } else {
                MetadataColumnExt metadataColumnExt = new MetadataColumnExt((MetadataColumn) copy);
                metadataColumnExt.setFunction(functionManagerExt.getDefaultFunction(metadataColumnExt, metadataColumnExt.getTalendType()));
                list.add(metadataColumnExt);
            }
        } else if (current instanceof org.talend.core.model.metadata.builder.connection.MetadataColumn) {
            MetadataTableEditor tableEditor = (MetadataTableEditor) extendedTable;
            org.talend.core.model.metadata.builder.connection.MetadataColumn metadataColumn = (org.talend.core.model.metadata.builder.connection.MetadataColumn) current;
            String nextGeneratedColumnName = metadataColumn.getLabel();
            //$NON-NLS-1$
            String tempNewColumnName = "";
            boolean iMetaColumnUnique = false;
            boolean metaColumnUnique = false;
            while (iMetaColumnUnique == false || metaColumnUnique == false) {
                nextGeneratedColumnName = tableEditor.getNextGeneratedColumnName(nextGeneratedColumnName, null);
                iMetaColumnUnique = true;
                metaColumnUnique = false;
                if (list.size() == 0)
                    metaColumnUnique = true;
                else {
                    tempNewColumnName = this.getUniqueString(list, nextGeneratedColumnName);
                    if (tempNewColumnName.equals(nextGeneratedColumnName))
                        metaColumnUnique = true;
                    else {
                        metaColumnUnique = false;
                        nextGeneratedColumnName = tempNewColumnName;
                    }
                }
            }
            org.talend.core.model.metadata.builder.connection.MetadataColumn newColumnCopy = new ConnectionFactoryImpl().copy(metadataColumn, nextGeneratedColumnName);
            IMetadataColumn copy = (ConvertionHelper.convertToIMetaDataColumn(newColumnCopy)).clone();
            copy.setLabel(nextGeneratedColumnName);
            MetadataColumnExt metadataColumnExt = new MetadataColumnExt((MetadataColumn) copy);
            metadataColumnExt.setFunction(functionManagerExt.getDefaultFunction(metadataColumnExt, metadataColumnExt.getTalendType()));
            list.add(metadataColumnExt);
            countList.add(nextGeneratedColumnName);
        }
    }
    return list;
}
Also used : MetadataTableEditor(org.talend.core.ui.metadata.editor.MetadataTableEditor) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) ConnectionFactoryImpl(org.talend.core.model.metadata.builder.connection.impl.ConnectionFactoryImpl)

Example 10 with IMetadataColumn

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

the class JSONFileOutputStep2Form method initLinker.

private void initLinker(TreeItem node, TableItem[] tableItems) {
    FOXTreeNode treeNode = (FOXTreeNode) node.getData();
    IMetadataColumn column = treeNode.getColumn();
    Properties prop = System.getProperties();
    String os = prop.getProperty("os.name");
    boolean isLastOne = false;
    if (column != null) {
        for (int i = 0; i < tableItems.length; i++) {
            MetadataColumn metadataColumn = (MetadataColumn) tableItems[i].getData();
            if (metadataColumn.getLabel().equals(column.getLabel())) {
                // "isLastOne" directly to false
                if (os.startsWith("Linux")) {
                    isLastOne = true;
                }
                linker.addLoopLink(tableItems[i], tableItems[i].getData(), JSONViewer.getTree(), treeNode, isLastOne);
                break;
            }
        }
    }
    TreeItem[] children = node.getItems();
    for (int i = 0; i < children.length; i++) {
        initLinker(children[i], tableItems);
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TreeItem(org.eclipse.swt.widgets.TreeItem) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Properties(java.util.Properties)

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