Search in sources :

Example 71 with IMetadataColumn

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

the class ExternalDataConverter method loadInExternalData.

private void loadInExternalData(List<? extends AbstractDataMapTable> tables, List<? extends AbstractDataMapTable> intables) {
    // for (int i = 0; i < tables.size(); i++) {
    if (tables.size() <= 0 || intables.size() <= 0) {
        return;
    }
    IDataMapTable outtable = tables.get(0);
    IDataMapTable intable = intables.get(0);
    ExternalMapperTable externalMapperTable = new ExternalMapperTable();
    fillExternalTable(outtable, externalMapperTable);
    ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
    List<IMetadataColumn> columnList = null;
    if (mapperManager != null && mapperManager.getAbstractMapComponent() != null) {
        List<? extends IConnection> connList = mapperManager.getAbstractMapComponent().getOutgoingConnections();
        if (connList != null && connList.size() >= 1) {
            List<IMetadataTable> metaList = connList.get(0).getTarget().getMetadataList();
            if (metaList != null && metaList.size() >= 1) {
                columnList = metaList.get(0).getListColumns();
            }
        }
    }
    for (ITableEntry dataMapTableEntry : intable.getColumnEntries()) {
        if (columnList != null) {
            boolean find = false;
            for (IMetadataColumn column : columnList) {
                if (dataMapTableEntry.getName().equals(column.getLabel())) {
                    find = true;
                    break;
                }
            }
            if (find) {
                ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
                externalMapperTableEntry.setExpression(intable.getName() + "." + dataMapTableEntry.getName());
                externalMapperTableEntry.setName(dataMapTableEntry.getName());
                externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
                externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
                perTableEntries.add(externalMapperTableEntry);
            }
        } else {
            ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
            externalMapperTableEntry.setExpression(intable.getName() + "." + dataMapTableEntry.getName());
            externalMapperTableEntry.setName(dataMapTableEntry.getName());
            externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
            externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
            perTableEntries.add(externalMapperTableEntry);
        }
    }
    externalMapperTable.setMetadataTableEntries(perTableEntries);
// }
}
Also used : ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)

Example 72 with IMetadataColumn

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

the class ShadowProcess method buildProcess.

private IProcess buildProcess() {
    IProcess ps = null;
    if (description.getEncoding() != null) {
        currentProcessEncoding = TalendTextUtils.removeQuotes(description.getEncoding());
    }
    FileOutputDelimitedNode outNode = new FileOutputDelimitedNode(TalendTextUtils.addQuotes("" + PathUtils.getPortablePath(outPath.toOSString())), //$NON-NLS-1$ 
    description.getEncoding());
    switch(type) {
        case FILE_DELIMITED:
        case FILE_CSV:
            FileInputDelimitedNode inDelimitedNode = new FileInputDelimitedNode(inPath, description.getRowSeparator(), description.getFieldSeparator(), description.getLimitRows(), description.getHeaderRow(), description.getFooterRow(), description.getEscapeCharacter(), description.getTextEnclosure(), description.getRemoveEmptyRowsToSkip(), description.isSplitRecord(), description.getEncoding(), type);
            ps = new FileinToDelimitedProcess<FileInputDelimitedNode>(inDelimitedNode, outNode);
            break;
        case FILE_POSITIONAL:
            FileInputPositionalNode inPositionalNode = new FileInputPositionalNode(inPath, description.getRowSeparator(), description.getPattern(), description.getHeaderRow(), description.getFooterRow(), description.getLimitRows(), description.getRemoveEmptyRowsToSkip(), description.getEncoding());
            outNode.setColumnNumber(inPositionalNode.getColumnNumber());
            ps = new FileinToDelimitedProcess<FileInputPositionalNode>(inPositionalNode, outNode);
            break;
        case FILE_REGEXP:
            FileInputRegExpNode inRegExpNode = new FileInputRegExpNode(inPath, description.getRowSeparator(), description.getPattern(), description.getLimitRows(), description.getHeaderRow(), description.getFooterRow(), description.getRemoveEmptyRowsToSkip(), description.getEncoding());
            ps = new FileinToDelimitedProcess<FileInputRegExpNode>(inRegExpNode, outNode);
            break;
        case FILE_XML:
            List<Map<String, String>> newmappings = new ArrayList<Map<String, String>>();
            List<Map<String, String>> oldmappings = description.getMapping();
            for (int i = 0; i < oldmappings.size(); i++) {
                Map<String, String> map = oldmappings.get(i);
                //$NON-NLS-1$ //$NON-NLS-2$
                map.put("SCHEMA_COLUMN", "row" + i);
                newmappings.add(map);
            }
            FileInputXmlNode inXmlNode = new FileInputXmlNode(inPath, description.getLoopQuery(), description.getMapping(), description.getLoopLimit(), description.getEncoding());
            ps = new FileinToDelimitedProcess<FileInputXmlNode>(inXmlNode, outNode);
            break;
        case FILE_EXCEL:
            // hywang add for excel 2007
            String versionCheck = "false";
            String afterRemoveQuotesPath = TalendTextUtils.removeQuotes(inPath);
            if (afterRemoveQuotesPath.toLowerCase().endsWith(".xlsx")) {
                versionCheck = "true";
            }
            FileInputExcelNode excelNode = null;
            ExcelSchemaBean excelBean = description.getExcelSchemaBean();
            excelNode = new FileInputExcelNode(inPath, description.getSchema(), //$NON-NLS-1$
            description.getEncoding() == null ? TalendTextUtils.addQuotes("ISO-8859-1") : description.getEncoding(), Integer.toString(description.getLimitRows()), Integer.toString(description.getHeaderRow()), Integer.toString(description.getFooterRow()), Boolean.toString(description.getRemoveEmptyRowsToSkip()), excelBean, versionCheck);
            outNode.setMetadataList(excelNode.getMetadataList());
            ps = new FileinToDelimitedProcess<FileInputExcelNode>(excelNode, outNode);
            break;
        case FILE_LDIF:
            outNode = new FileOutputDelimitedForLDIF(TalendTextUtils.addQuotes(//$NON-NLS-1$
            "" + PathUtils.getPortablePath(outPath.toOSString())), description.getEncoding());
            FileInputLdifNode inLdifNode = new FileInputLdifNode(inPath, description.getSchema(), description.getEncoding());
            outNode.setMetadataList(inLdifNode.getMetadataList());
            ps = new FileinToDelimitedProcess<FileInputLdifNode>(inLdifNode, outNode);
            break;
        case LDAP_SCHEMA:
            // outNode = new FileOutputDelimitedForLDIF(TalendTextUtils.addQuotes(""
            // + PathUtils.getPortablePath(outPath.toOSString())), description.getEncoding());
            LDAPSchemaInputNode inLDAPSchemaNode = new LDAPSchemaInputNode(TalendTextUtils.addQuotes(//$NON-NLS-1$
            "" + PathUtils.getPortablePath(outPath.toOSString())), description.getSchema(), description.getEncoding(), description.getLdapSchemaBean());
            List<IMetadataTable> metadataList = inLDAPSchemaNode.getMetadataList();
            for (IMetadataTable metadataTable : metadataList) {
                // for bug15450
                List<IMetadataColumn> listColumns = metadataTable.getListColumns();
                for (IMetadataColumn metadataColumn : listColumns) {
                    String label = metadataColumn.getLabel();
                    boolean validColumnName = MetadataToolHelper.isValidColumnName(label);
                    if (!validColumnName) {
                        metadataColumn.setLabel(label.replaceAll("[^a-zA-Z0-9_]", "_"));
                    }
                }
            }
            outNode.setMetadataList(metadataList);
            ps = new FileinToDelimitedProcess<LDAPSchemaInputNode>(inLDAPSchemaNode, outNode);
            break;
        case WSDL_SCHEMA:
            // outNode = new FileOutputDelimitedForLDIF(TalendTextUtils.addQuotes(""
            // + PathUtils.getPortablePath(outPath.toOSString())), description.getEncoding());
            WSDLSchemaInputNode inWSDLSchemaNode = new WSDLSchemaInputNode(TalendTextUtils.addQuotes(//$NON-NLS-1$
            "" + PathUtils.getPortablePath(outPath.toOSString())), description.getEncoding(), description.getSchema(), description.getWsdlSchemaBean(), description.getWsdlSchemaBean().getParameters());
            outNode.setMetadataList(inWSDLSchemaNode.getMetadataList());
            ps = new FileinToDelimitedProcess<WSDLSchemaInputNode>(inWSDLSchemaNode, outNode);
            break;
        case SALESFORCE_SCHEMA:
            SalesforceSchemaInputNode inSalesforceNode = new SalesforceSchemaInputNode(description.getSchema(), description.getSalesforceSchemaBean());
            outNode.setMetadataList(inSalesforceNode.getMetadataList());
            SalesforceSchemaBean salesforceSchemaBean = description.getSalesforceSchemaBean();
            boolean uesHttp = salesforceSchemaBean.isUesHttp();
            salesforceSchemaBean.isUseProxy();
            if (uesHttp) {
                String proxyHost = salesforceSchemaBean.getProxyHost();
                String proxyPort = salesforceSchemaBean.getProxyPort();
                String userName = salesforceSchemaBean.getProxyUsername();
                String password = salesforceSchemaBean.getProxyPassword();
                final Prejob prejob = new Prejob("");
                final SetProxy setProxy = new SetProxy("HTTP_PROXY", proxyHost, proxyPort, userName, password, proxyHost + "|" + proxyPort);
                ps = new FileinToDelimitedProcess<SalesforceSchemaInputNode>(inSalesforceNode, outNode, prejob, setProxy);
            } else {
                ps = new FileinToDelimitedProcess<SalesforceSchemaInputNode>(inSalesforceNode, outNode);
            }
            break;
        default:
            break;
    }
    return ps;
}
Also used : ArrayList(java.util.ArrayList) ExcelSchemaBean(org.talend.core.repository.model.preview.ExcelSchemaBean) SalesforceSchemaBean(org.talend.core.repository.model.preview.SalesforceSchemaBean) IProcess(org.talend.core.model.process.IProcess) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Map(java.util.Map)

Example 73 with IMetadataColumn

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

the class FilterColumnDialog method initChecked.

private void initChecked() {
    List<ConditionBean> beans = new ArrayList<ConditionBean>();
    for (IMetadataColumn column : conn.getMetadataTable().getListColumns()) {
        ConditionBean bean = new ConditionBean(column);
        bean.setCondition(TracesConnectionUtils.getTracesColumnCondition(conn, column.getLabel()));
        beans.add(bean);
    }
    tabView.setInput(beans);
    List<String> enabledTraceColumns = TracesConnectionUtils.getEnabledTraceColumns(conn);
    for (TableItem item : tabView.getTable().getItems()) {
        Object data = item.getData();
        if (data instanceof ConditionBean) {
            ConditionBean bean = (ConditionBean) data;
            if (enabledTraceColumns.contains(bean.getColumnName())) {
                tabView.setChecked(bean, true);
            }
        }
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 74 with IMetadataColumn

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

the class PropertiesTableEditorModel method isButtonEnabled.

/**
     * 
     * DOC Added for featerue TDI-7284
     * 
     * @return
     */
public boolean isButtonEnabled() {
    if (element instanceof Node && relatedParameter != null) {
        Node node = (Node) element;
        if (node.getMetadataList() != null && node.getMetadataList().get(0).getListColumns() != null) {
            List<IMetadataColumn> columns = node.getMetadataList().get(0).getListColumns();
            boolean foundNotExistColumn = false;
            for (IMetadataColumn column : columns) {
                if (!exist(column.getLabel())) {
                    foundNotExistColumn = true;
                    break;
                }
            }
            if (foundNotExistColumn) {
                return true;
            } else {
                return false;
            }
        }
    }
    return true;
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 75 with IMetadataColumn

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

the class PropertiesTableToolbarEditorView method createAddPushButton.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.ui.extended.ExtendedToolbarView#createAddPushButton()
     */
@Override
protected AddPushButton createAddPushButton() {
    final AddPushButton addPushButton = new AddPushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {

        @Override
        public boolean getEnabledState() {
            if (model != null && !model.getElemParameter().getElement().isReadOnly() && (model.getElemParameter().getName().equals("HADOOP_ADVANCED_PROPERTIES") || model.getElemParameter().getName().equals("HBASE_PARAMETERS") || model.getElemParameter().getName().equals("SPARK_ADVANCED_PROPERTIES")) && !model.getElemParameter().isRepositoryValueUsed()) {
                return true;
            }
            return super.getEnabledState() && (model == null || !model.getElemParameter().isBasedOnSubjobStarts());
        }

        @Override
        protected Object getObjectToAdd() {
            PropertiesTableEditorModel tableEditorModel = (PropertiesTableEditorModel) getExtendedTableViewer().getExtendedControlModel();
            if (!tableEditorModel.isButtonEnabled()) {
                MessageDialog.openInformation(tableEditorModel.getTableViewer().getControl().getShell(), "Information", "All output columns have been added already");
                return null;
            }
            Object newEntry = tableEditorModel.createNewEntry();
            if (tableEditorModel.isAggregateRow() && newEntry instanceof Map) {
                List<ColumnInfo> tableInputs = new ArrayList<ColumnInfo>();
                String[] displayNames = tableEditorModel.getElemParameter().getListItemsDisplayName();
                Object[] itemsValue = tableEditorModel.getElemParameter().getListItemsValue();
                // default name //$NON-NLS-1$
                String paramColumnsName = "COLUMN";
                for (int i = 0; i < itemsValue.length; i++) {
                    if (itemsValue[i] instanceof IElementParameter) {
                        IElementParameter tableParameter = (IElementParameter) itemsValue[i];
                        if (tableParameter.getFieldType().equals(EParameterFieldType.COLUMN_LIST)) {
                            paramColumnsName = tableParameter.getName();
                        } else {
                            ColumnInfo row = new ColumnInfo();
                            row.name = displayNames[i];
                            row.parameter = tableParameter;
                            row.defaultValue = "";
                            tableInputs.add(row);
                        }
                    }
                }
                Node node = (Node) tableEditorModel.getElement();
                String outputTableName = null;
                if (node.getMetadataList() != null && !node.getMetadataList().isEmpty()) {
                    IMetadataTable metadata = node.getMetadataList().get(0);
                    if (metadata.getListColumns() != null) {
                        for (IMetadataColumn column : metadata.getListColumns()) {
                            if (!tableEditorModel.exist(column.getLabel())) {
                                outputTableName = column.getLabel();
                                break;
                            }
                        }
                    }
                }
                if (outputTableName != null) {
                    Map mapObject = (Map) newEntry;
                    if (mapObject.containsKey(paramColumnsName)) {
                        mapObject.put(paramColumnsName, outputTableName);
                    }
                    for (ColumnInfo col : tableInputs) {
                        Object defaultValue = col.defaultValue;
                        Object found = findDefaultName(outputTableName, col);
                        if (found != null && !"".equals(found)) {
                            defaultValue = found;
                        }
                        if (defaultValue != null && !"".equals(defaultValue)) {
                            mapObject.put(col.parameter.getName(), defaultValue);
                        }
                    }
                }
            }
            return newEntry;
        }
    };
    // TDI-6568, after added, fire change
    addPushButton.addListener(getPropertyChangeListener(), false);
    return addPushButton;
}
Also used : AddPushButton(org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButton) AddPushButtonForExtendedTable(org.talend.commons.ui.swt.advanced.dataeditor.button.AddPushButtonForExtendedTable) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) ColumnInfo(org.talend.designer.core.ui.editor.properties.macrowidgets.tableeditor.PromptDefaultValueDialog.ColumnInfo) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) HashMap(java.util.HashMap) Map(java.util.Map)

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