use of org.talend.metadata.managment.ui.model.IConnParamName in project tdi-studio-se by Talend.
the class GenericContextUtil method setPropertiesForContextMode.
public static void setPropertiesForContextMode(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
if (connection == null) {
return;
}
if (connection instanceof GenericConnection) {
GenericConnection genericConn = (GenericConnection) connection;
ComponentProperties componentProperties = getComponentProperties(genericConn);
String originalVariableName = prefixName + ConnectionContextHelper.LINE;
String genericVariableName = null;
for (IConnParamName param : paramSet) {
if (param instanceof GenericConnParamName) {
GenericConnParamName genericParam = (GenericConnParamName) param;
String paramVarName = genericParam.getContextVar();
genericVariableName = originalVariableName + paramVarName;
matchContextForAttribues(componentProperties, genericParam, genericVariableName);
}
}
updateComponentProperties(genericConn, componentProperties);
}
}
use of org.talend.metadata.managment.ui.model.IConnParamName in project tdi-studio-se by Talend.
the class GenericContextHandler method exportContext.
@Override
public boolean exportContext(ConnectionItem connectionItem) {
boolean isContextMode = connectionItem.getConnection().isContextMode();
if (isContextMode) {
ConnectionContextHelper.openInConetxtModeDialog();
} else {
String defaultContextName = ConnectionContextHelper.convertContextLabel(connectionItem.getProperty().getLabel());
if (StringUtils.isEmpty(defaultContextName)) {
//$NON-NLS-1$ //$NON-NLS-2$
MessageDialog.openError(DisplayUtils.getDefaultShell(), Messages.getString("GenericContextHandler.wizardTitle"), Messages.getString("GenericContextHandler.defineConnectionName"));
}
Set<IConnParamName> contextParams = getContextParams();
Map<ContextItem, List<ConectionAdaptContextVariableModel>> variableModels = ConnectionContextHelper.exportAsContext(defaultContextName, connectionItem, contextParams);
if (variableModels != null) {
Iterator<ContextItem> contextItor = variableModels.keySet().iterator();
while (contextItor.hasNext()) {
ContextItem contextItem = contextItor.next();
List<ConectionAdaptContextVariableModel> apaptModels = variableModels.get(contextItem);
if (contextItem != null && apaptModels.size() == 0) {
// create
if (ConnectionContextHelper.contextManager instanceof JobContextManager) {
Map<String, String> map = ((JobContextManager) ConnectionContextHelper.contextManager).getNameMap();
// set properties for context mode
ConnectionContextHelper.setPropertiesForContextMode(defaultContextName, connectionItem, contextItem, contextParams, map);
}
} else {
// set properties for exist context
ConnectionContextHelper.setPropertiesForExistContextMode(connectionItem, contextParams, variableModels);
}
}
}
return true;
}
return false;
}
use of org.talend.metadata.managment.ui.model.IConnParamName in project tdi-studio-se by Talend.
the class GenericContextHandler method getContextParams.
@Override
public Set<IConnParamName> getContextParams() {
Set<IConnParamName> contextParams = new HashSet<>();
if (parameters != null) {
for (IElementParameter param : parameters) {
if (param instanceof GenericElementParameter) {
GenericElementParameter genericElementParameter = (GenericElementParameter) param;
if (genericElementParameter.isSupportContext()) {
GenericConnParamName connParamName = new GenericConnParamName();
String paramName = genericElementParameter.getName();
connParamName.setName(paramName);
connParamName.setContextVar(getValidContextVarName(paramName));
contextParams.add(connParamName);
}
}
}
}
return contextParams;
}
use of org.talend.metadata.managment.ui.model.IConnParamName in project tdi-studio-se by Talend.
the class GenericContextUtil method setPropertiesForExistContextMode.
public static void setPropertiesForExistContextMode(Connection connection, Set<IConnParamName> paramSet, Map<ContextItem, List<ConectionAdaptContextVariableModel>> adaptMap) {
if (connection == null) {
return;
}
if (connection instanceof GenericConnection) {
GenericConnection genericConn = (GenericConnection) connection;
ComponentProperties componentProperties = getComponentProperties(genericConn);
ContextItem currentContext = null;
for (IConnParamName param : paramSet) {
if (param instanceof GenericConnParamName) {
String genericVariableName = null;
GenericConnParamName genericParam = (GenericConnParamName) param;
if (adaptMap != null && adaptMap.size() > 0) {
for (Map.Entry<ContextItem, List<ConectionAdaptContextVariableModel>> entry : adaptMap.entrySet()) {
currentContext = entry.getKey();
List<ConectionAdaptContextVariableModel> modelList = entry.getValue();
for (ConectionAdaptContextVariableModel model : modelList) {
if (model.getValue().equals(genericParam.getName())) {
genericVariableName = model.getName();
break;
}
}
}
}
if (genericVariableName != null) {
genericVariableName = getCorrectVariableName(currentContext, genericVariableName, genericParam);
matchContextForAttribues(componentProperties, genericParam, genericVariableName);
}
}
}
updateComponentProperties(genericConn, componentProperties);
}
}
use of org.talend.metadata.managment.ui.model.IConnParamName 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