Search in sources :

Example 1 with RegexpFileConnection

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

the class DynamicComposite method updateRepositoryListExtra.

/**
     * for job settings extra (feature 2710).
     * 
     */
private void updateRepositoryListExtra(IElementParameter param, List<String> repositoryConnectionNameList, List<String> repositoryConnectionValueList, boolean extra) {
    String repositoryValue = param.getParentParameter().getRepositoryValue();
    if (repositoryValue != null) {
        List<String> connectionNamesList = new ArrayList<String>();
        List<String> connectionValuesList = new ArrayList<String>();
        for (String key : repositoryConnectionItemMap.keySet()) {
            ConnectionItem connectionItem = repositoryConnectionItemMap.get(key);
            Connection connection = connectionItem.getConnection();
            String name = //$NON-NLS-1$
            getRepositoryAliasName(connectionItem) + ":" + connectionItem.getProperty().getLabel();
            if ((connection instanceof DelimitedFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.DELIMITED.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof PositionalFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.POSITIONAL.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof RegexpFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.REGEX.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof XmlFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.XML.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof FileExcelConnection) && (repositoryValue.equals(ERepositoryCategoryType.EXCEL.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof GenericSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.GENERIC.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof LDAPSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.LDAP.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof SalesforceSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.SALESFORCE.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof WSDLSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.WSDL.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof DatabaseConnection) && (repositoryValue.startsWith(ERepositoryCategoryType.DATABASE.getName()))) {
                //$NON-NLS-1$
                String currentDbType = (String) RepositoryToComponentProperty.getValue(connection, "TYPE", null);
                if (repositoryValue.contains(":")) {
                    // database //$NON-NLS-1$
                    // is
                    // specified
                    // //$NON-NLS-1$
                    //$NON-NLS-1$
                    String neededDbType = repositoryValue.substring(repositoryValue.indexOf(":") + 1);
                    if (neededDbType.equals(currentDbType)) {
                        addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
                    }
                } else {
                    addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
                }
            }
        }
        repositoryConnectionNameList.addAll(connectionNamesList);
        repositoryConnectionValueList.addAll(connectionValuesList);
    } else {
        List<String> connectionValuesList = new ArrayList<String>();
        List<String> connectionStringList = new ArrayList<String>();
        for (String key : repositoryConnectionItemMap.keySet()) {
            ConnectionItem connectionItem = repositoryConnectionItemMap.get(key);
            String name = connectionItem.getProperty().getLabel();
            addOrderDisplayNames(connectionValuesList, connectionStringList, key, name);
        }
        repositoryConnectionNameList.addAll(connectionStringList);
        repositoryConnectionValueList.addAll(connectionValuesList);
    }
    param.setListItemsDisplayName(repositoryConnectionNameList.toArray(new String[0]));
    param.setListItemsValue(repositoryConnectionValueList.toArray(new String[0]));
    if (!repositoryConnectionItemMap.keySet().contains(param.getValue())) {
        if (repositoryConnectionNameList.size() > 0) {
            param.setValue(repositoryConnectionValueList.get(0));
        }
    }
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) ArrayList(java.util.ArrayList) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) SalesforceSchemaConnection(org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection) WSDLSchemaConnection(org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection) GenericSchemaConnection(org.talend.core.model.metadata.builder.connection.GenericSchemaConnection) PositionalFileConnection(org.talend.core.model.metadata.builder.connection.PositionalFileConnection) RegexpFileConnection(org.talend.core.model.metadata.builder.connection.RegexpFileConnection) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) QueriesConnection(org.talend.core.model.metadata.builder.connection.QueriesConnection) LDAPSchemaConnection(org.talend.core.model.metadata.builder.connection.LDAPSchemaConnection) FileExcelConnection(org.talend.core.model.metadata.builder.connection.FileExcelConnection) FileExcelConnection(org.talend.core.model.metadata.builder.connection.FileExcelConnection) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) RegexpFileConnection(org.talend.core.model.metadata.builder.connection.RegexpFileConnection) PositionalFileConnection(org.talend.core.model.metadata.builder.connection.PositionalFileConnection) SalesforceSchemaConnection(org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection) GenericSchemaConnection(org.talend.core.model.metadata.builder.connection.GenericSchemaConnection) LDAPSchemaConnection(org.talend.core.model.metadata.builder.connection.LDAPSchemaConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) WSDLSchemaConnection(org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection)

Example 2 with RegexpFileConnection

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

the class DynamicTabbedPropertySection method updateRepositoryListExtra.

private void updateRepositoryListExtra(IElementParameter param, String[] repositoryConnectionNameList, String[] repositoryConnectionValueList, boolean extra) {
    String paramName = EParameterName.PROPERTY_TYPE.getName();
    // if (extra) {
    // paramName = extraPropertyTypeName;
    // }
    String repositoryValue = elem.getElementParameter(paramName).getRepositoryValue();
    if (repositoryValue != null) {
        List<String> connectionNamesList = new ArrayList<String>();
        List<String> connectionValuesList = new ArrayList<String>();
        for (String key : repositoryConnectionItemMap.keySet()) {
            ConnectionItem connectionItem = repositoryConnectionItemMap.get(key);
            Connection connection = connectionItem.getConnection();
            String name = //$NON-NLS-1$
            getRepositoryAliasName(connectionItem) + ":" + connectionItem.getProperty().getLabel();
            if ((connection instanceof DelimitedFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.DELIMITED.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof PositionalFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.POSITIONAL.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof RegexpFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.REGEX.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof XmlFileConnection) && (repositoryValue.equals(ERepositoryCategoryType.XML.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof FileExcelConnection) && (repositoryValue.equals(ERepositoryCategoryType.EXCEL.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof GenericSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.GENERIC.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof LDAPSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.LDAP.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof SalesforceSchemaConnection) && (repositoryValue.equals(ERepositoryCategoryType.SALESFORCE.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
            if ((connection instanceof DatabaseConnection) && (repositoryValue.startsWith(ERepositoryCategoryType.DATABASE.getName()))) {
                //$NON-NLS-1$
                String currentDbType = (String) RepositoryToComponentProperty.getValue(connection, "TYPE", null);
                if (repositoryValue.contains(":")) {
                    // database //$NON-NLS-1$
                    // is
                    // specified
                    // //$NON-NLS-1$
                    //$NON-NLS-1$
                    String neededDbType = repositoryValue.substring(repositoryValue.indexOf(":") + 1);
                    if (neededDbType.equals(currentDbType)) {
                        addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
                    }
                } else {
                    addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
                }
            }
            if ((connection instanceof HeaderFooterConnection) && (repositoryValue.equals(ERepositoryCategoryType.HEADERFOOTER.getName()))) {
                addOrderDisplayNames(connectionValuesList, connectionNamesList, key, name);
            }
        }
        repositoryConnectionNameList = connectionNamesList.toArray(new String[0]);
        repositoryConnectionValueList = connectionValuesList.toArray(new String[0]);
    } else {
        List<String> connectionValuesList = new ArrayList<String>();
        List<String> connectionStringList = new ArrayList<String>();
        for (String key : repositoryConnectionItemMap.keySet()) {
            ConnectionItem connectionItem = repositoryConnectionItemMap.get(key);
            String name = connectionItem.getProperty().getLabel();
            addOrderDisplayNames(connectionValuesList, connectionStringList, key, name);
        }
        repositoryConnectionNameList = connectionStringList.toArray(new String[0]);
        repositoryConnectionValueList = connectionValuesList.toArray(new String[0]);
    }
    param.setListItemsDisplayName(repositoryConnectionNameList);
    param.setListItemsValue(repositoryConnectionValueList);
    if (!repositoryConnectionItemMap.keySet().contains(param.getValue())) {
        if (repositoryConnectionNameList.length > 0) {
            // paramName = EParameterName.REPOSITORY_PROPERTY_TYPE.getName();
            // if (extra) {
            // paramName = extraRepositoryPropertyTypeName;
            // }
            elem.setPropertyValue(paramName, repositoryConnectionValueList[0]);
        }
    }
}
Also used : ConnectionItem(org.talend.core.model.properties.ConnectionItem) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) ArrayList(java.util.ArrayList) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) SalesforceSchemaConnection(org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection) GenericSchemaConnection(org.talend.core.model.metadata.builder.connection.GenericSchemaConnection) PositionalFileConnection(org.talend.core.model.metadata.builder.connection.PositionalFileConnection) RegexpFileConnection(org.talend.core.model.metadata.builder.connection.RegexpFileConnection) IConnection(org.talend.core.model.process.IConnection) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) HeaderFooterConnection(org.talend.core.model.metadata.builder.connection.HeaderFooterConnection) XmlFileConnection(org.talend.core.model.metadata.builder.connection.XmlFileConnection) QueriesConnection(org.talend.core.model.metadata.builder.connection.QueriesConnection) LDAPSchemaConnection(org.talend.core.model.metadata.builder.connection.LDAPSchemaConnection) FileExcelConnection(org.talend.core.model.metadata.builder.connection.FileExcelConnection) FileExcelConnection(org.talend.core.model.metadata.builder.connection.FileExcelConnection) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) RegexpFileConnection(org.talend.core.model.metadata.builder.connection.RegexpFileConnection) PositionalFileConnection(org.talend.core.model.metadata.builder.connection.PositionalFileConnection) SalesforceSchemaConnection(org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection) GenericSchemaConnection(org.talend.core.model.metadata.builder.connection.GenericSchemaConnection) LDAPSchemaConnection(org.talend.core.model.metadata.builder.connection.LDAPSchemaConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) HeaderFooterConnection(org.talend.core.model.metadata.builder.connection.HeaderFooterConnection)

Aggregations

ArrayList (java.util.ArrayList)2 Connection (org.talend.core.model.metadata.builder.connection.Connection)2 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)2 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)2 FileExcelConnection (org.talend.core.model.metadata.builder.connection.FileExcelConnection)2 GenericSchemaConnection (org.talend.core.model.metadata.builder.connection.GenericSchemaConnection)2 LDAPSchemaConnection (org.talend.core.model.metadata.builder.connection.LDAPSchemaConnection)2 PositionalFileConnection (org.talend.core.model.metadata.builder.connection.PositionalFileConnection)2 QueriesConnection (org.talend.core.model.metadata.builder.connection.QueriesConnection)2 RegexpFileConnection (org.talend.core.model.metadata.builder.connection.RegexpFileConnection)2 SalesforceSchemaConnection (org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection)2 XmlFileConnection (org.talend.core.model.metadata.builder.connection.XmlFileConnection)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2 HeaderFooterConnection (org.talend.core.model.metadata.builder.connection.HeaderFooterConnection)1 WSDLSchemaConnection (org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection)1 IConnection (org.talend.core.model.process.IConnection)1