Search in sources :

Example 11 with ElementParameter

use of org.talend.designer.core.model.components.ElementParameter in project tdi-studio-se by Talend.

the class ProjectSettingManager method createImplicitContextLoadParameters.

/**
     *
     * create parameter for ImplicitContextLoad.
     */
static void createImplicitContextLoadParameters(Element elem) {
    ElementParameter param;
    List<IElementParameter> paramList = (List<IElementParameter>) elem.getElementParameters();
    param = new ElementParameter(elem);
    param.setName(EParameterName.UPDATE_COMPONENTS.getName());
    param.setValue(Boolean.FALSE);
    param.setDisplayName(EParameterName.UPDATE_COMPONENTS.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.STATSANDLOGS);
    param.setNumRow(1);
    param.setReadOnly(true);
    param.setRequired(false);
    param.setShow(false);
    paramList.add(param);
    param = new ElementParameter(elem);
    param.setName(EParameterName.IMPLICIT_TCONTEXTLOAD.getName());
    param.setValue(preferenceStore.getBoolean(getPreferenceName(EParameterName.IMPLICIT_TCONTEXTLOAD)));
    param.setGroupDisplayName(EParameterName.IMPLICIT_TCONTEXTLOAD.getDisplayName());
    param.setDisplayName(EParameterName.IMPLICIT_TCONTEXTLOAD.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.EXTRA);
    param.setGroup(IMPLICIT_GROUP);
    param.setNumRow(3);
    param.setShow(true);
    paramList.add(param);
    param = new ElementParameter(elem);
    param.setName(EParameterName.IMPLICT_DEFAULT_PROJECTSETTING.getName());
    param.setValue(Boolean.TRUE);
    param.setGroupDisplayName(EParameterName.IMPLICT_DEFAULT_PROJECTSETTING.getDisplayName());
    param.setDisplayName(EParameterName.IMPLICT_DEFAULT_PROJECTSETTING.getDisplayName());
    param.setFieldType(EParameterFieldType.CHECK);
    param.setCategory(EComponentCategory.EXTRA);
    param.setGroup(IMPLICIT_GROUP);
    param.setNumRow(3);
    param.setShow(false);
    paramList.add(param);
    // on files
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.FROM_FILE_FLAG.getName()));
    param.setValue(preferenceStore.getBoolean(getPreferenceName(EParameterName.FROM_FILE_FLAG)));
    param.setDisplayName(EParameterName.FROM_FILE_FLAG.getDisplayName());
    param.setFieldType(EParameterFieldType.RADIO);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(4);
    param.setShowIf(JobSettingsConstants.addBrackets(CONTEXTLOAD_CONDITION));
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // on database
    param = new ElementParameter(elem);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.FROM_DATABASE_FLAG.getName()));
    param.setValue(preferenceStore.getBoolean(getPreferenceName(EParameterName.FROM_DATABASE_FLAG)));
    param.setDisplayName(EParameterName.FROM_DATABASE_FLAG.getDisplayName());
    param.setFieldType(EParameterFieldType.RADIO);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(5);
    param.setShowIf(JobSettingsConstants.addBrackets(CONTEXTLOAD_CONDITION));
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // on file
    createExtraOnFileParameters(elem);
    // on database
    createExtraOnDBParameters(elem);
    // tContextLoad
    createExtraContextLoadParameters(elem);
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList)

Example 12 with ElementParameter

use of org.talend.designer.core.model.components.ElementParameter in project tdi-studio-se by Talend.

the class ParallelExecutionUtils method setHashKeysFromTarget.

public static void setHashKeysFromTarget(IConnection con, Node target) {
    List<String> targetKeyColumnList = getColumnListFromTargetNode(target);
    IElementParameter parTableCon = con.getElementParameter(HASH_KEYS);
    boolean isExistHashValue = false;
    if (parTableCon != null) {
        ((List) parTableCon.getValue()).clear();
        if (targetKeyColumnList.size() > 0) {
            con.getElementParameter(HASH_PARTION).setValue(true);
            Object[] itemCon = parTableCon.getListItemsValue();
            String clumnKeyListName = "";
            for (Object itemList : itemCon) {
                if (((ElementParameter) itemList).getFieldType().equals(EParameterFieldType.PREV_COLUMN_LIST) || ((ElementParameter) itemList).getFieldType().equals(EParameterFieldType.COLUMN_LIST)) {
                    clumnKeyListName = ((ElementParameter) itemList).getName();
                    break;
                }
            }
            for (String partionValue : targetKeyColumnList) {
                for (Object keyParMap : ((List) parTableCon.getValue())) {
                    Map existKeyMap = (Map) keyParMap;
                    if (existKeyMap.get(clumnKeyListName).equals(partionValue)) {
                        isExistHashValue = true;
                        break;
                    }
                }
                if (!isExistHashValue) {
                    Map partionKeyMap = new HashMap<String, String>();
                    partionKeyMap.put(clumnKeyListName, partionValue);
                    ((List) parTableCon.getValue()).add(partionKeyMap);
                }
            }
        }
    }
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) HashMap(java.util.HashMap) IElementParameter(org.talend.core.model.process.IElementParameter) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with ElementParameter

use of org.talend.designer.core.model.components.ElementParameter in project tdi-studio-se by Talend.

the class ParallelExecutionUtils method getColumnListFromTargetNode.

public static List<String> getColumnListFromTargetNode(Node target) {
    List<String> columnKeyValues = new ArrayList<String>();
    IElementParameter parTableNode = target.getElementParameterFromField(EParameterFieldType.TABLE);
    if (parTableNode != null) {
        Object[] itemNode = parTableNode.getListItemsValue();
        ElementParameter clumnNodeList = null;
        for (Object itemList : itemNode) {
            if (((ElementParameter) itemList).getFieldType().equals(EParameterFieldType.PREV_COLUMN_LIST) || ((ElementParameter) itemList).getFieldType().equals(EParameterFieldType.COLUMN_LIST)) {
                clumnNodeList = ((ElementParameter) itemList);
                break;
            }
        }
        if (clumnNodeList != null) {
            for (Map nodeColumnListMap : (List<Map>) parTableNode.getValue()) {
                Object value = nodeColumnListMap.get(clumnNodeList.getName());
                if (nodeColumnListMap.get(clumnNodeList.getName()) instanceof String) {
                    columnKeyValues.add((String) value);
                } else if (value instanceof Integer) {
                    Integer index = (Integer) value;
                    if (clumnNodeList.getListItemsDisplayName().length > index) {
                        columnKeyValues.add(clumnNodeList.getListItemsDisplayName()[index]);
                    }
                }
            }
        }
    }
    return columnKeyValues;
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) 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)

Example 14 with ElementParameter

use of org.talend.designer.core.model.components.ElementParameter in project tdi-studio-se by Talend.

the class ParallelExecutionUtils method reSetParKeyValuesForCon.

public static void reSetParKeyValuesForCon(IConnection parConnection) {
    IElementParameter parTableCon = parConnection.getElementParameter(HASH_KEYS);
    if (parTableCon != null) {
        Object[] itemCon = parTableCon.getListItemsValue();
        ElementParameter conElemForList = null;
        String clumnKeyListName = "";
        for (Object itemList : itemCon) {
            if (((ElementParameter) itemList).getFieldType().equals(EParameterFieldType.PREV_COLUMN_LIST) || ((ElementParameter) itemList).getFieldType().equals(EParameterFieldType.COLUMN_LIST)) {
                conElemForList = (ElementParameter) itemList;
                clumnKeyListName = ((ElementParameter) itemList).getName();
            }
        }
        List<String> parKeyValues = new ArrayList<String>();
        if (conElemForList != null) {
            for (Map conColumnListMap : (List<Map>) parTableCon.getValue()) {
                if (conColumnListMap.get(clumnKeyListName) instanceof String) {
                    parKeyValues.add((String) conColumnListMap.get(clumnKeyListName));
                }
                if (conColumnListMap.get(clumnKeyListName) instanceof Integer) {
                    Integer index = (Integer) conColumnListMap.get(clumnKeyListName);
                    parKeyValues.add((String) conElemForList.getListItemsValue()[index]);
                    // if the value of key is Integer index,need to set it back to the value
                    if (conElemForList.getListItemsDisplayName().length > index) {
                        conColumnListMap.put(clumnKeyListName, conElemForList.getListItemsDisplayName()[index]);
                    }
                }
            }
        }
    }
}
Also used : IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) 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)

Example 15 with ElementParameter

use of org.talend.designer.core.model.components.ElementParameter in project tdi-studio-se by Talend.

the class JobSettingsManager method getExtraOnDBParameters.

private static List<IElementParameter> getExtraOnDBParameters(IProcess process) {
    ElementParameter param;
    List<IElementParameter> paramList = new ArrayList<IElementParameter>();
    IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
    //$NON-NLS-1$
    String languagePrefix = LanguageManager.getCurrentLanguage().toString() + "_";
    final String onDBCondition = JobSettingsConstants.getExtraParameterName(EParameterName.FROM_DATABASE_FLAG.getName()) + //$NON-NLS-1$
    " == 'true'";
    final String dbCondition = JobSettingsConstants.addBrackets(CONTEXTLOAD_CONDITION) + " and " + //$NON-NLS-1$
    JobSettingsConstants.addBrackets(onDBCondition);
    // property type
    ElementParameter parentPropertyType = new ElementParameter(process);
    parentPropertyType.setName(JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTY_TYPE.getName()));
    parentPropertyType.setDisplayName(EParameterName.PROPERTY_TYPE.getDisplayName());
    //$NON-NLS-1$
    parentPropertyType.setValue("");
    parentPropertyType.setCategory(EComponentCategory.EXTRA);
    parentPropertyType.setFieldType(EParameterFieldType.PROPERTY_TYPE);
    parentPropertyType.setRepositoryValue(ERepositoryCategoryType.DATABASE.getName());
    parentPropertyType.setNumRow(41);
    parentPropertyType.setShowIf(dbCondition);
    parentPropertyType.setGroup(IMPLICIT_GROUP);
    paramList.add(parentPropertyType);
    param = new ElementParameter(process);
    param.setName(EParameterName.PROPERTY_TYPE.getName());
    param.setDisplayName(EParameterName.PROPERTY_TYPE.getDisplayName());
    param.setListItemsDisplayName(new String[] { EmfComponent.TEXT_BUILTIN, EmfComponent.TEXT_REPOSITORY });
    param.setListItemsDisplayCodeName(new String[] { EmfComponent.BUILTIN, EmfComponent.REPOSITORY });
    param.setListItemsValue(new String[] { EmfComponent.BUILTIN, EmfComponent.REPOSITORY });
    param.setValue(EmfComponent.BUILTIN);
    param.setCategory(EComponentCategory.EXTRA);
    param.setFieldType(EParameterFieldType.TECHNICAL);
    param.setRepositoryValue(ERepositoryCategoryType.DATABASE.getName());
    param.setNumRow(41);
    param.setShowIf(dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    param.setParentParameter(parentPropertyType);
    // paramList.add(param);
    // repository property type
    param = new ElementParameter(process);
    param.setName(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
    param.setDisplayName(EParameterName.REPOSITORY_PROPERTY_TYPE.getDisplayName());
    param.setListItemsDisplayName(new String[] {});
    param.setListItemsValue(new String[] {});
    // param.setValue(""); //$NON-NLS-1$
    param.setCategory(EComponentCategory.EXTRA);
    param.setFieldType(EParameterFieldType.TECHNICAL);
    param.setShow(false);
    param.setRequired(true);
    param.setNumRow(41);
    param.setGroup(IMPLICIT_GROUP);
    param.setParentParameter(parentPropertyType);
    // paramList.add(param);
    // dbType
    final String dbTypeName = JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName());
    param = new ElementParameter(process);
    param.setName(dbTypeName);
    param.setDisplayName(EParameterName.DB_TYPE.getDisplayName());
    param.setFieldType(EParameterFieldType.CLOSED_LIST);
    param.setCategory(EComponentCategory.EXTRA);
    param.setListItemsDisplayName(StatsAndLogsConstants.DISPLAY_DBNAMES[1]);
    param.setListItemsValue(JobSettingsConstants.DB_INPUT_COMPONENTS[1]);
    param.setListRepositoryItems(StatsAndLogsConstants.REPOSITORY_ITEMS[1]);
    param.setListItemsDisplayCodeName(StatsAndLogsConstants.CODE_LIST[1]);
    param.setValue("");
    param.setNumRow(42);
    //$NON-NLS-1$
    param.setRepositoryValue("TYPE");
    param.setRequired(true);
    param.setShowIf(dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // dbVersion
    final String dbVersionName = JobSettingsConstants.getExtraParameterName(EParameterName.DB_VERSION.getName());
    if (process.getElementParameter(dbVersionName) == null) {
        param = new ElementParameter(process);
        param.setName(dbVersionName);
        param.setValue(StatsAndLogsConstants.DB_VERSION_DRIVER[1]);
        param.setDisplayName(EParameterName.DB_VERSION.getDisplayName());
        param.setFieldType(EParameterFieldType.CLOSED_LIST);
        param.setCategory(EComponentCategory.EXTRA);
        param.setListItemsDisplayName(StatsAndLogsConstants.DB_VERSION_DISPLAY);
        param.setListItemsValue(StatsAndLogsConstants.DB_VERSION_DRIVER);
        param.setListItemsDisplayCodeName(StatsAndLogsConstants.DB_VERSION_CODE);
        param.setNumRow(42);
        //$NON-NLS-1$
        param.setRepositoryValue("DB_VERSION");
        param.setRequired(true);
        param.setShowIf(dbCondition + " and (" + dbTypeName + " == 'OCLE' or " + dbTypeName + " == 'OCLE_OCI' or " + dbTypeName + " =='ACCESS' or " + dbTypeName + " =='MSSQL' or " + dbTypeName + //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$
        " =='MYSQL') ");
        param.setGroup(IMPLICIT_GROUP);
        paramList.add(param);
    }
    // jdbc url
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.URL.getName()));
    param.setValue(StatsAndLogsManager.addQuotes(preferenceStore.getString(languagePrefix + EParameterName.URL.getName())));
    param.setDisplayName(EParameterName.URL.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(43);
    //$NON-NLS-1$
    param.setRepositoryValue("URL");
    String dbCon = dbTypeName + " == 'JDBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // jdbc child param
    if (moduleNameList == null) {
        List<ModuleNeeded> moduleNeededList = ModulesNeededProvider.getModulesNeeded();
        moduleNameList = new ArrayList<String>();
        moduleValueList = new ArrayList<String>();
        for (ModuleNeeded module : moduleNeededList) {
            String moduleName = module.getModuleName();
            if (moduleName != null) {
                if (!moduleNameList.contains(moduleName)) {
                    moduleNameList.add(moduleName);
                }
                String moduleValue = TalendTextUtils.addQuotes(moduleName);
                if (!moduleValueList.contains(moduleValue)) {
                    moduleValueList.add(moduleValue);
                }
            }
        }
        Comparator<String> comprarator = new IgnoreCaseComparator();
        Collections.sort(moduleNameList, comprarator);
        Collections.sort(moduleValueList, comprarator);
    }
    String[] moduleNameArray = moduleNameList.toArray(new String[0]);
    String[] moduleValueArray = moduleValueList.toArray(new String[0]);
    ElementParameter childParam = new ElementParameter(process);
    childParam.setName("JAR_NAME");
    childParam.setDisplayName("JAR_NAME");
    childParam.setFieldType(EParameterFieldType.MODULE_LIST);
    childParam.setListItemsDisplayName(moduleNameArray);
    childParam.setListItemsValue(moduleValueArray);
    // driver jar for jdbc
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_JAR.getName()));
    param.setDisplayName(EParameterName.DRIVER_JAR.getDisplayName());
    param.setFieldType(EParameterFieldType.TABLE);
    param.setListItemsDisplayCodeName(new String[] { "JAR_NAME" });
    param.setListItemsDisplayName(new String[] { "Jar Name" });
    param.setListItemsValue(new ElementParameter[] { childParam });
    param.setValue(new ArrayList<Map<String, Object>>());
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(44);
    //$NON-NLS-1$
    param.setRepositoryValue("DRIVER_JAR");
    dbCon = dbTypeName + " == 'JDBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // class name for jdbc
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_CLASS.getName()));
    param.setValue(StatsAndLogsManager.addQuotes(preferenceStore.getString(languagePrefix + EParameterName.DRIVER_CLASS.getName())));
    param.setDisplayName(EParameterName.DRIVER_CLASS.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(45);
    //$NON-NLS-1$
    param.setRepositoryValue("DRIVER_CLASS");
    dbCon = dbTypeName + " == 'JDBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // host
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.HOST.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.HOST.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(46);
    //$NON-NLS-1$
    param.setRepositoryValue("SERVER_NAME");
    dbCon = dbTypeName + " != 'SQLITE'" + " and " + dbTypeName + " != 'ACCESS'" + " and " + dbTypeName + "!='OCLE_OCI'" + " and " + dbTypeName + "!='JDBC'" + " and " + dbTypeName + //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$
    "!='ODBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // port
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.PORT.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.PORT.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(46);
    //$NON-NLS-1$
    param.setRepositoryValue("PORT");
    dbCon = dbTypeName + " != 'SQLITE'" + " and " + dbTypeName + " != 'ACCESS'" + " and " + dbTypeName + " != 'FIREBIRD'" + " and " + dbTypeName + "!='OCLE_OCI'" + " and " + dbTypeName + "!='JDBC'" + " and " + dbTypeName + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$
    "!='ODBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // dbName
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DBNAME.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.DBNAME.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(47);
    //$NON-NLS-1$
    param.setRepositoryValue("SID");
    dbCon = dbTypeName + " != 'SQLITE'" + " and " + dbTypeName + " != 'ACCESS'" + " and " + dbTypeName + " != 'FIREBIRD'" + " and " + dbTypeName + "!='OCLE_OCI'" + " and " + dbTypeName + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$
    "!='JDBC'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // local service name
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.LOCAL_SERVICE_NAME.getName()));
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.LOCAL_SERVICE_NAME.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(47);
    //$NON-NLS-1$
    param.setRepositoryValue("SID");
    dbCon = dbTypeName + " =='OCLE_OCI' ";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // additional parameters
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTIES.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.PROPERTIES.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(47);
    //$NON-NLS-1$
    param.setRepositoryValue("PROPERTIES_STRING");
    dbCon = dbTypeName + " == 'MSSQL'" + " or " + dbTypeName + " == 'MYSQL'" + " or " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    dbTypeName + " == 'INFORMIX'" + " or " + dbTypeName + " == 'OCLE'" + " or " + dbTypeName + " == 'OCLE_OCI'" + " or " + dbTypeName + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
    " == 'SYBASE'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // schema
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.SCHEMA_DB.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.SCHEMA_DB.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(47);
    //$NON-NLS-1$
    param.setRepositoryValue("SCHEMA");
    final String schemaCondition = JobSettingsConstants.addBrackets(dbTypeName + " =='OCLE' or " + //$NON-NLS-1$
    dbTypeName + " =='POSTGRESQL' or " + dbTypeName + " =='POSTGRESPLUS' or " + dbTypeName + " =='OCLE_OCI' or " + dbTypeName + " =='MSSQL' or " + dbTypeName + " =='INFORMIX' or " + dbTypeName + " =='IBM_DB2' or " + dbTypeName + //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$
    " =='SYBASE'");
    //$NON-NLS-1$
    param.setShowIf(schemaCondition + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // username
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.USER.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.USER.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(48);
    param.setRequired(true);
    //$NON-NLS-1$
    param.setRepositoryValue("USERNAME");
    //$NON-NLS-1$
    dbCon = dbTypeName + " != 'SQLITE'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // password
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.PASS.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.PASS.getDisplayName());
    param.setFieldType(EParameterFieldType.PASSWORD);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(48);
    param.setRequired(true);
    //$NON-NLS-1$
    param.setRepositoryValue("PASSWORD");
    //$NON-NLS-1$
    dbCon = dbTypeName + " != 'SQLITE'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // databse file path
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DBFILE.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.DBFILE.getDisplayName());
    param.setFieldType(EParameterFieldType.FILE);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(49);
    //$NON-NLS-1$
    param.setRepositoryValue("FILE");
    //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
    dbCon = dbTypeName + " == 'SQLITE'" + " or " + dbTypeName + " == 'ACCESS'" + " or " + dbTypeName + " == 'FIREBIRD'";
    //$NON-NLS-1$
    param.setShowIf(JobSettingsConstants.addBrackets(dbCon) + " and " + dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // table
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DBTABLE.getName()));
    //$NON-NLS-1$
    param.setValue(StatsAndLogsManager.addQuotes(""));
    param.setDisplayName(EParameterName.DBTABLE.getDisplayName());
    param.setFieldType(EParameterFieldType.DBTABLE);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(50);
    param.setShowIf(dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    // query condition
    param = new ElementParameter(process);
    param.setName(JobSettingsConstants.getExtraParameterName(EParameterName.QUERY_CONDITION.getName()));
    param.setValue(QUOTE + QUOTE);
    param.setDisplayName(EParameterName.QUERY_CONDITION.getDisplayName());
    param.setFieldType(EParameterFieldType.TEXT);
    param.setCategory(EComponentCategory.EXTRA);
    param.setNumRow(51);
    param.setShowIf(dbCondition);
    param.setGroup(IMPLICIT_GROUP);
    paramList.add(param);
    for (IElementParameter currentParam : paramList) {
        if (currentParam.getRepositoryValue() != null) {
            // if any of the parameter of stat&logs is using repository, then force to link it to the name of the
            // property for implicit
            currentParam.setRepositoryProperty(parentPropertyType.getName());
        }
    }
    return paramList;
}
Also used : ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Map(java.util.Map)

Aggregations

ElementParameter (org.talend.designer.core.model.components.ElementParameter)72 IElementParameter (org.talend.core.model.process.IElementParameter)62 ArrayList (java.util.ArrayList)44 List (java.util.List)26 INode (org.talend.core.model.process.INode)20 Map (java.util.Map)19 HashMap (java.util.HashMap)15 Node (org.talend.designer.core.ui.editor.nodes.Node)12 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)11 GenericElementParameter (org.talend.designer.core.generic.model.GenericElementParameter)10 Test (org.junit.Test)9 IComponent (org.talend.core.model.components.IComponent)8 ComponentProperties (org.talend.components.api.properties.ComponentProperties)7 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)7 IConnection (org.talend.core.model.process.IConnection)7 Form (org.talend.daikon.properties.presentation.Form)6 ModuleNeeded (org.talend.core.model.general.ModuleNeeded)5 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)5 INodeConnector (org.talend.core.model.process.INodeConnector)5 IProcess (org.talend.core.model.process.IProcess)4