use of org.talend.metadata.managment.ui.utils.GenericConnParamName in project tdi-studio-se by Talend.
the class GenericContextUtil method createContextParameters.
public static List<IContextParameter> createContextParameters(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
List<IContextParameter> varList = new ArrayList<>();
if (connection instanceof GenericConnection) {
GenericConnection conn = (GenericConnection) connection;
if (conn == null || prefixName == null || paramSet == null || paramSet.isEmpty()) {
return Collections.emptyList();
}
String paramPrefix = prefixName + ConnectionContextHelper.LINE;
String paramName = null;
for (IConnParamName param : paramSet) {
if (param instanceof GenericConnParamName) {
GenericConnParamName connParamName = (GenericConnParamName) param;
String name = connParamName.getName();
ComponentProperties componentProperties = getComponentProperties((GenericConnection) connection);
Property<?> property = componentProperties.getValuedProperty(name);
paramName = paramPrefix + connParamName.getContextVar();
JavaType type = JavaTypesManager.STRING;
if (property.isFlag(Property.Flags.ENCRYPT)) {
type = JavaTypesManager.PASSWORD;
}
if (GenericTypeUtils.isIntegerType(property)) {
type = JavaTypesManager.INTEGER;
}
String value = property == null || property.getValue() == null ? null : StringEscapeUtils.escapeJava(String.valueOf(property.getValue()));
ConnectionContextHelper.createParameters(varList, paramName, value, type);
}
}
}
return varList;
}
Aggregations