Search in sources :

Example 1 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class PostgresGenerationManager method getHandledTableName.

protected String getHandledTableName(DbMapComponent component, String name, String aliasName, boolean generateSubSql) {
    List<IConnection> inputConnections = (List<IConnection>) component.getIncomingConnections();
    if (inputConnections == null) {
        return name;
    }
    for (IConnection iconn : inputConnections) {
        boolean inputIsELTDBMap = false;
        INode source = iconn.getSource();
        String schemaStr = "";
        String tableNameStr = "";
        if (source != null) {
            inputIsELTDBMap = isELTDBMap(source);
            if (inputIsELTDBMap) {
                tableNameStr = iconn.getName();
            } else {
                IElementParameter schema = source.getElementParameter("ELT_SCHEMA_NAME");
                IElementParameter tableName = source.getElementParameter("ELT_TABLE_NAME");
                if (schema != null && schema.getValue() != null) {
                    schemaStr = TalendTextUtils.removeQuotes(schema.getValue().toString());
                }
                if (tableName != null && tableName.getValue() != null) {
                    tableNameStr = TalendTextUtils.removeQuotes(tableName.getValue().toString());
                }
            }
        }
        String tableName = schemaStr;
        if ("".equals(tableName)) {
            tableName = tableNameStr;
        } else {
            if (!"".equals(tableNameStr)) {
                tableName = tableName + "." + tableNameStr;
            }
        }
        if (tableName.equals(name)) {
            StringBuffer sb = new StringBuffer();
            if (inputIsELTDBMap && generateSubSql) {
                DbMapComponent externalNode = null;
                if (source instanceof DbMapComponent) {
                    externalNode = (DbMapComponent) source;
                } else {
                    externalNode = (DbMapComponent) source.getExternalNode();
                }
                DbGenerationManager genManager = externalNode.getGenerationManager();
                String deliveredTable = genManager.buildSqlSelect(externalNode, iconn.getMetadataTable().getTableName(), //$NON-NLS-1$
                tabSpaceString + "  ");
                int begin = 1;
                int end = deliveredTable.length() - 1;
                if (begin <= end) {
                    //$NON-NLS-1$ //$NON-NLS-2$
                    sb.append("(").append(DbMapSqlConstants.NEW_LINE).append(tabSpaceString).append("  ");
                    sb.append(deliveredTable.substring(begin, end)).append(DbMapSqlConstants.NEW_LINE).append(tabSpaceString).append(//$NON-NLS-1$
                    " ) ");
                }
                if (aliasName != null && !aliasName.trim().isEmpty()) {
                    tableNameStr = aliasName;
                }
            }
            StringBuffer tempExp = getSchemaAndTable(schemaStr, tableNameStr);
            sb.append(tempExp);
            return sb.toString();
        }
    }
    return name;
}
Also used : INode(org.talend.core.model.process.INode) DbMapComponent(org.talend.designer.dbmap.DbMapComponent) DbGenerationManager(org.talend.designer.dbmap.language.generation.DbGenerationManager) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) IConnection(org.talend.core.model.process.IConnection)

Example 2 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class MultiSchemasManager method retrievePropertiesFromNode.

/**
     * 
     * cLi Comment method "retrievePropertiesFromNode".
     * 
     */
@SuppressWarnings("unchecked")
public SchemasKeyData retrievePropertiesFromNode() {
    //$NON-NLS-1$
    SchemasKeyData rootData = new SchemasKeyData("");
    IElementParameter elementParameter = getMultiSchemasComponent().getElementParameter(EParameterName.SCHEMAS.getName());
    final Object value = elementParameter.getValue();
    if (value == null) {
        return null;
    }
    List<Map<String, String>> schemasValues = (List<Map<String, String>>) value;
    createSimpleDatas(rootData, schemasValues);
    retrieveRelativeParent(rootData, schemasValues);
    return rootData;
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData) Map(java.util.Map)

Example 3 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class ChangeMultiSchemasCommand method initNew.

private void initNew(Object object) {
    if (fakeConnection != null) {
        this.newFieldSeperator = fakeConnection.getFieldSeparatorValue();
        this.newRowSeperator = fakeConnection.getRowSeparatorValue();
        this.newEncoding = TalendTextUtils.addQuotes(fakeConnection.getEncoding());
        IElementParameter encodingType = node.getElementParameter(EParameterName.ENCODING_TYPE.getName());
        if (encodingType != null) {
            String[] codes = encodingType.getListItemsDisplayCodeName();
            if (codes != null) {
                List<String> list = Arrays.asList(codes);
                if (list.indexOf(fakeConnection.getEncoding()) > -1) {
                    this.newEncodingType = fakeConnection.getEncoding();
                } else {
                    // custom
                    this.newEncodingType = list.get(list.size() - 1);
                }
            }
        }
        this.newFilePath = fakeConnection.getFilePath();
        this.newTextEnclosure = fakeConnection.getTextEnclosure();
        this.newEscapeChar = fakeConnection.getEscapeChar();
        this.newCsvOption = fakeConnection.isCsvOption();
        this.newSelectedColumnIndex = TalendTextUtils.QUOTATION_MARK + String.valueOf(object) + TalendTextUtils.QUOTATION_MARK;
    } else if (params != null) {
        this.newFieldSeperator = params.get(EParameterName.FIELDSEPARATOR);
        this.newRowSeperator = params.get(EParameterName.ROWSEPARATOR);
        this.newEncoding = params.get(EParameterName.ENCODING);
        this.newEncodingType = params.get(EParameterName.ENCODING_TYPE);
        this.newFilePath = params.get(EParameterName.FILENAME);
        this.newTextEnclosure = params.get(EParameterName.TEXT_ENCLOSURE);
        this.newEscapeChar = params.get(EParameterName.ESCAPE_CHAR);
        this.newCsvOption = Boolean.valueOf(params.get(EParameterName.CSV_OPTION));
        this.newUseMultiSaparator = Boolean.valueOf(params.get(EParameterName.USE_MULTISEPARATORS));
        this.newSaparators = params.get(EParameterName.MULTI_SEPARATORS);
        this.newSelectedColumnIndex = params.get(EParameterName.COLUMNINDEX);
        this.newKeyValues = params.get(EParameterName.MULTI_KEYVALUES);
    }
    // map
    this.newSchemasListMap = new ArrayList<Map<String, String>>();
    // metadata table
    this.newMetadataTable = new ArrayList<IMetadataTable>();
    // hywang add for feature7373
    addSchemasMap(newSchemasListMap, newMetadataTable, this.rootSchemaData);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class ChangeMultiSchemasCommand method setParameterValues.

private void setParameterValues(boolean undo) {
    IElementParameter elementParameter = null;
    setParameterValues(EParameterName.FILENAME, this.oldFilePath, this.newFilePath, undo);
    setParameterValues(EParameterName.ENCODING_TYPE, this.oldEncodingType, this.newEncodingType, undo);
    setParameterValues(EParameterName.ENCODING, this.oldEncoding, this.newEncoding, undo);
    setParameterValues(EParameterName.ROWSEPARATOR, this.oldRowSeperator, this.newRowSeperator, undo);
    setParameterValues(EParameterName.FIELDSEPARATOR, this.oldFieldSeperator, this.newFieldSeperator, undo);
    setParameterValues(EParameterName.TEXT_ENCLOSURE, this.oldTextEnclosure, this.newTextEnclosure, undo);
    setParameterValues(EParameterName.ESCAPE_CHAR, this.oldEscapeChar, this.newEscapeChar, undo);
    setParameterValues(EParameterName.CSV_OPTION, this.oldCsvOption, this.newCsvOption, undo);
    setParameterValues(EParameterName.COLUMNINDEX, this.oldSelectedColumnIndex, this.newSelectedColumnIndex, undo);
    setParameterValues(EParameterName.USE_MULTISEPARATORS, this.oldUseMultiSaparator, this.newUseMultiSaparator, undo);
    setParameterValues(EParameterName.MULTI_SEPARATORS, this.oldSaparators, this.newSaparators, undo);
    setParameterValues(EParameterName.MULTI_KEYVALUES, this.oldKeyValues, this.newKeyValues, undo);
    // PTODO need check again.
    elementParameter = this.node.getElementParameter(EParameterName.SCHEMAS.getName());
    if (elementParameter != null) {
        List<Map<String, String>> value = null;
        if (undo) {
            value = this.oldSchemasListMap;
        } else {
            value = this.newSchemasListMap;
        }
        elementParameter.setValue(value);
    }
    if (undo) {
        if (this.oldMetadataTable != null) {
            addMetadataTable(this.oldMetadataTable);
        }
    } else {
        if (this.newMetadataTable != null) {
            addMetadataTable(this.newMetadataTable);
        }
    }
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with IElementParameter

use of org.talend.core.model.process.IElementParameter in project tdi-studio-se by Talend.

the class ChangeMultiSchemasCommand method initOld.

private void initOld() {
    if (node == null) {
        return;
    }
    IElementParameter elementParameter = this.node.getElementParameter(EParameterName.FILENAME.getName());
    if (elementParameter != null) {
        this.oldFilePath = elementParameter.getValue();
    }
    elementParameter = this.node.getElementParameter(EParameterName.ENCODING_TYPE.getName());
    if (elementParameter != null) {
        this.oldEncodingType = elementParameter.getValue();
    }
    elementParameter = this.node.getElementParameter(EParameterName.ENCODING.getName());
    if (elementParameter != null) {
        this.oldEncoding = elementParameter.getValue();
    }
    elementParameter = this.node.getElementParameter(EParameterName.ROWSEPARATOR.getName());
    if (elementParameter != null) {
        this.oldRowSeperator = elementParameter.getValue();
    }
    elementParameter = this.node.getElementParameter(EParameterName.FIELDSEPARATOR.getName());
    if (elementParameter != null) {
        this.oldFieldSeperator = elementParameter.getValue();
    }
    elementParameter = this.node.getElementParameter(EParameterName.TEXT_ENCLOSURE.getName());
    if (elementParameter != null) {
        this.oldTextEnclosure = elementParameter.getValue();
    }
    elementParameter = this.node.getElementParameter(EParameterName.ESCAPE_CHAR.getName());
    if (elementParameter != null) {
        this.oldEscapeChar = elementParameter.getValue();
    }
    elementParameter = this.node.getElementParameter(EParameterName.CSV_OPTION.getName());
    if (elementParameter != null) {
        this.oldCsvOption = (Boolean) elementParameter.getValue();
    }
    // hywang add for feature7373
    elementParameter = this.node.getElementParameter(EParameterName.COLUMNINDEX.getName());
    if (elementParameter != null) {
        this.oldSelectedColumnIndex = String.valueOf(elementParameter.getValue());
    }
    elementParameter = this.node.getElementParameter(EParameterName.MULTI_SEPARATORS.getName());
    if (elementParameter != null) {
        this.oldSaparators = String.valueOf(elementParameter.getValue());
    }
    elementParameter = this.node.getElementParameter(EParameterName.USE_MULTISEPARATORS.getName());
    if (elementParameter != null) {
        this.oldUseMultiSaparator = (Boolean) elementParameter.getValue();
    }
    elementParameter = this.node.getElementParameter(EParameterName.MULTI_KEYVALUES.getName());
    if (elementParameter != null) {
        this.oldKeyValues = String.valueOf(elementParameter.getValue());
    }
    // schema table
    elementParameter = this.node.getElementParameter(EParameterName.SCHEMAS.getName());
    if (elementParameter != null) {
        Object value = elementParameter.getValue();
        List<Map<String, String>> oldvalueList = new ArrayList<Map<String, String>>();
        if (value != null) {
            List<Map<String, String>> valueList = (List<Map<String, String>>) value;
            for (Map<String, String> map : valueList) {
                Map<String, String> valueMap = new HashMap<String, String>();
                for (String key : map.keySet()) {
                    valueMap.put(key, map.get(key));
                }
                oldvalueList.add(valueMap);
            }
        }
        this.oldSchemasListMap = oldvalueList;
    }
    // metadata
    List<IMetadataTable> oldMetadataTable = new ArrayList<IMetadataTable>();
    for (IMetadataTable table : this.node.getMetadataList()) {
        oldMetadataTable.add(table.clone(true));
    }
    this.oldMetadataTable = oldMetadataTable;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

IElementParameter (org.talend.core.model.process.IElementParameter)439 ArrayList (java.util.ArrayList)165 List (java.util.List)112 Node (org.talend.designer.core.ui.editor.nodes.Node)108 Map (java.util.Map)99 INode (org.talend.core.model.process.INode)94 HashMap (java.util.HashMap)87 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)73 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)69 Point (org.eclipse.swt.graphics.Point)57 ElementParameter (org.talend.designer.core.model.components.ElementParameter)48 ConnectionItem (org.talend.core.model.properties.ConnectionItem)45 IConnection (org.talend.core.model.process.IConnection)40 PersistenceException (org.talend.commons.exception.PersistenceException)39 Item (org.talend.core.model.properties.Item)38 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)37 IComponent (org.talend.core.model.components.IComponent)36 CCombo (org.eclipse.swt.custom.CCombo)33 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)29 Connection (org.talend.core.model.metadata.builder.connection.Connection)28