use of org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName in project tbd-studio-se by Talend.
the class HadoopClusterContextHandler method setPropertiesForContextMode.
@Override
public void setPropertiesForContextMode(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
if (connection == null) {
return;
}
if (connection instanceof HadoopClusterConnection) {
HadoopClusterConnection hadoopConn = (HadoopClusterConnection) connection;
String originalVariableName = prefixName + ConnectionContextHelper.LINE;
String hadoopVariableName = null;
for (IConnParamName param : paramSet) {
if (param instanceof EHadoopParamName) {
EHadoopParamName hadoopConnectionParam = (EHadoopParamName) param;
originalVariableName = prefixName + ConnectionContextHelper.LINE;
hadoopVariableName = originalVariableName + hadoopConnectionParam;
matchContextForAttribues(hadoopConn, hadoopConnectionParam, hadoopVariableName);
}
}
String hadoopProperties = hadoopConn.getHadoopProperties();
List<Map<String, Object>> propertiesAfterContext = transformHadoopPropertiesForContextMode(HadoopRepositoryUtil.getHadoopPropertiesList(hadoopProperties), prefixName);
hadoopConn.setHadoopProperties(HadoopRepositoryUtil.getHadoopPropertiesJsonStr(propertiesAfterContext));
//
String sparkProperties = hadoopConn.getSparkProperties();
List<Map<String, Object>> sparkPropertiesAfterContext = transformHadoopPropertiesForContextMode(HadoopRepositoryUtil.getHadoopPropertiesList(sparkProperties), prefixName);
hadoopConn.setSparkProperties(HadoopRepositoryUtil.getHadoopPropertiesJsonStr(sparkPropertiesAfterContext));
}
}
use of org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName in project tbd-studio-se by Talend.
the class HadoopClusterContextHandler method createContextParameters.
@Override
public List<IContextParameter> createContextParameters(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
List<IContextParameter> varList = new ArrayList<IContextParameter>();
if (connection instanceof HadoopClusterConnection) {
HadoopClusterConnection conn = (HadoopClusterConnection) connection;
String paramPrefix = prefixName + ConnectionContextHelper.LINE;
String paramName = null;
for (IConnParamName param : paramSet) {
if (param instanceof EHadoopParamName) {
EHadoopParamName hadoopParam = (EHadoopParamName) param;
paramName = paramPrefix + hadoopParam;
switch(hadoopParam) {
case NameNodeUri:
ConnectionContextHelper.createParameters(varList, paramName, conn.getNameNodeURI());
break;
case JobTrackerUri:
ConnectionContextHelper.createParameters(varList, paramName, conn.getJobTrackerURI());
break;
case ResourceManager:
ConnectionContextHelper.createParameters(varList, paramName, conn.getJobTrackerURI());
break;
case ResourceManagerScheduler:
ConnectionContextHelper.createParameters(varList, paramName, conn.getRmScheduler());
break;
case JobHistory:
ConnectionContextHelper.createParameters(varList, paramName, conn.getJobHistory());
break;
case StagingDirectory:
ConnectionContextHelper.createParameters(varList, paramName, conn.getStagingDirectory());
break;
case NameNodePrin:
ConnectionContextHelper.createParameters(varList, paramName, conn.getPrincipal());
break;
case JTOrRMPrin:
ConnectionContextHelper.createParameters(varList, paramName, conn.getJtOrRmPrincipal());
break;
case JobHistroyPrin:
ConnectionContextHelper.createParameters(varList, paramName, conn.getJobHistoryPrincipal());
break;
case User:
ConnectionContextHelper.createParameters(varList, paramName, conn.getUserName());
break;
case Group:
ConnectionContextHelper.createParameters(varList, paramName, conn.getGroup());
break;
case Principal:
ConnectionContextHelper.createParameters(varList, paramName, conn.getKeytabPrincipal());
break;
case KeyTab:
ConnectionContextHelper.createParameters(varList, paramName, conn.getKeytab());
break;
case maprTPassword:
ConnectionContextHelper.createParameters(varList, paramName, conn.getMaprTPassword(), JavaTypesManager.PASSWORD);
break;
case maprTCluster:
ConnectionContextHelper.createParameters(varList, paramName, conn.getMaprTCluster());
break;
case maprTDuration:
ConnectionContextHelper.createParameters(varList, paramName, conn.getMaprTDuration(), JavaTypesManager.LONG);
break;
case maprTHomeDir:
ConnectionContextHelper.createParameters(varList, paramName, conn.getMaprTHomeDir());
break;
case maprTHadoopLogin:
ConnectionContextHelper.createParameters(varList, paramName, conn.getMaprTHadoopLogin());
break;
case WebHostName:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_WEB_HCAT_HOSTNAME));
break;
case WebPort:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_WEB_HCAT_PORT));
break;
case WebUser:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_WEB_HCAT_USERNAME));
break;
case WebJobResFolder:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_WEB_HCAT_JOB_RESULT_FOLDER));
break;
case HDIUser:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HDI_USERNAME));
break;
case HDIPassword:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HDI_PASSWORD), JavaTypesManager.PASSWORD);
break;
case KeyAzureHost:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_AZURE_HOSTNAME));
break;
case KeyAzureContainer:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_AZURE_CONTAINER));
break;
case KeyAzuresUser:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_AZURE_USERNAME));
break;
case KeyAzurePassword:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_AZURE_PASSWORD), JavaTypesManager.PASSWORD);
break;
case KeyAzureDeployBlob:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_AZURE_DEPLOY_BLOB));
break;
case GoogleProjectId:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_GOOGLE_PROJECT_ID));
break;
case GoogleClusterId:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_GOOGLE_CLUSTER_ID));
break;
case GoogleRegion:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_GOOGLE_REGION));
break;
case GoogleJarsBucket:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_GOOGLE_JARS_BUCKET));
break;
case PathToGoogleCredentials:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_PATH_TO_GOOGLE_CREDENTIALS));
break;
case DataBricksEndpoint:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DATABRICKS_ENDPOINT));
break;
case DataBricksCloudProvider:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DATABRICKS_CLOUD_PROVIDER));
break;
case DatabricksRunMode:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DATABRICKS_RUN_MODE));
break;
case DataBricksClusterId:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DATABRICKS_CLUSTER_ID));
break;
case DataBricksToken:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DATABRICKS_TOKEN), JavaTypesManager.PASSWORD);
break;
case DataBricksDBFSDepFolder:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DATABRICKS_DBFS_DEP_FOLDER));
break;
case setHadoopConf:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SET_HADOOP_CONF), JavaTypesManager.BOOLEAN);
break;
case hadoopConfSpecificJar:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CONF_SPECIFIC_JAR));
break;
case WebHDFSSSLTrustStorePath:
ConnectionContextHelper.createParameters(varList, paramName, conn.getWebHDFSSSLTrustStorePath());
break;
case WebHDFSSSLTrustStorePassword:
ConnectionContextHelper.createParameters(varList, paramName, conn.getWebHDFSSSLTrustStorePassword(), JavaTypesManager.PASSWORD);
break;
case UseKnox:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USE_KNOX));
break;
case SparkMode:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SPARK_MODE));
break;
case KnoxUrl:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KNOX_URL));
break;
case KnoxUsername:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KNOX_USER));
break;
case KnoxPassword:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KNOX_PASSWORD), JavaTypesManager.PASSWORD);
break;
case KnoxDirectory:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KNOX_DIRECTORY));
break;
case SynapseHostName:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_HOST));
break;
case SynapseAuthToken:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_AUTH_TOKEN), JavaTypesManager.PASSWORD);
break;
case SynapseSparkPools:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_SPARK_POOLS));
break;
case SynapseFsHostName:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_FS_HOSTNAME));
break;
case SynapseFsContainer:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_FS_CONTAINER));
break;
case SynapseFsUserName:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_FS_USERNAME));
break;
case SynapseFsPassword:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_FS_PASSWORD), JavaTypesManager.PASSWORD);
break;
case SynapseDeployBlob:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_DEPLOY_BLOB));
break;
case SynapseDriverMemory:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DRIVER_MEMORY));
break;
case SynapseDriverCores:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DRIVER_CORES));
break;
case SynapseExecutorMemory:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_EXECUTOR_MEMORY));
break;
case UseTuningProperties:
ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_TUNING_PROPERTIES));
break;
default:
}
}
}
createHadoopPropertiesContextVariable(prefixName, varList, conn.getHadoopProperties());
createHadoopPropertiesContextVariable(prefixName, varList, conn.getSparkProperties());
}
return varList;
}
use of org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName in project tbd-studio-se by Talend.
the class NoSQLRepositoryContextHandler method createContextParameters.
@Override
public List<IContextParameter> createContextParameters(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
List<IContextParameter> varList = new ArrayList<IContextParameter>();
if (connection instanceof NoSQLConnection) {
NoSQLConnection conn = (NoSQLConnection) connection;
JavaType javaType = null;
if (conn == null || prefixName == null || paramSet == null || paramSet.isEmpty()) {
return Collections.emptyList();
}
for (Map.Entry<String, String> attr : ((NoSQLConnection) connection).getAttributes()) {
if (INoSQLCommonAttributes.PASSWORD.equals(attr)) {
javaType = JavaTypesManager.PASSWORD;
}
}
String paramPrefix = prefixName + ConnectionContextHelper.LINE;
String paramName = null;
for (IConnParamName param : paramSet) {
if (param instanceof EHadoopParamName) {
EHadoopParamName noSqlParam = (EHadoopParamName) param;
paramName = paramPrefix + noSqlParam;
switch(noSqlParam) {
case Server:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(INoSQLCommonAttributes.HOST), javaType);
break;
case Port:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(INoSQLCommonAttributes.PORT), javaType);
break;
case Keyspace:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(INoSQLCommonAttributes.DATABASE), javaType);
break;
case Database:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(INoSQLCommonAttributes.DATABASE), javaType);
break;
case Databasepath:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(INeo4jAttributes.DATABASE_PATH), javaType);
break;
case ServerUrl:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(INeo4jAttributes.SERVER_URL), javaType);
break;
case UserName:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(INoSQLCommonAttributes.USERNAME), javaType);
break;
case Password:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(INoSQLCommonAttributes.PASSWORD), JavaTypesManager.PASSWORD);
break;
case ConnectionString:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(IMongoDBAttributes.CONN_STRING), javaType);
break;
case Keystore:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(IMongoDBAttributes.X509_CERT), javaType);
break;
case KeystorePass:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(IMongoDBAttributes.X509_CERT_KEYSTORE_PASSWORD), JavaTypesManager.PASSWORD);
break;
case Truststore:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(IMongoDBAttributes.X509_CERT_AUTH), javaType);
break;
case TruststorePass:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(IMongoDBAttributes.X509_CERT_AUTH_TRUSTSTORE_PASSWORD), JavaTypesManager.PASSWORD);
break;
case AuthenticationDatabase:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(IMongoDBAttributes.AUTHENTICATION_DATABASE), javaType);
break;
case UserPrincipal:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(IMongoDBAttributes.KRB_USER_PRINCIPAL), javaType);
break;
case Realm:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(IMongoDBAttributes.KRB_REALM), javaType);
break;
case KDCServer:
ConnectionContextHelper.createParameters(varList, paramName, conn.getAttributes().get(IMongoDBAttributes.KRB_KDC), javaType);
break;
case ReplicaSets:
String replicaSets = conn.getAttributes().get(IMongoDBAttributes.REPLICA_SET);
if (StringUtils.isNotEmpty(replicaSets)) {
try {
JSONArray jsa = new JSONArray(replicaSets);
for (int i = 0; i < jsa.length(); i++) {
JSONObject jso = jsa.getJSONObject(i);
String hostParamName = paramPrefix + EHadoopParamName.ReplicaHost.name() + ConnectionContextHelper.LINE + (i + 1);
String portParamName = paramPrefix + EHadoopParamName.ReplicaPort.name() + ConnectionContextHelper.LINE + (i + 1);
String hostValue = jso.getString(IMongoConstants.REPLICA_HOST_KEY);
String portValue = jso.getString(IMongoConstants.REPLICA_PORT_KEY);
ConnectionContextHelper.createParameters(varList, hostParamName, hostValue, JavaTypesManager.STRING);
ConnectionContextHelper.createParameters(varList, portParamName, portValue, JavaTypesManager.INTEGER);
}
} catch (JSONException e) {
ExceptionHandler.process(e);
}
}
break;
default:
}
}
}
}
return varList;
}
use of org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName in project tbd-studio-se by Talend.
the class NoSQLRepositoryContextHandler method matchContextForAttribues.
@Override
protected void matchContextForAttribues(Connection conn, IConnParamName param, String noSqlVariableName) {
NoSQLConnection noSqlConn = (NoSQLConnection) conn;
EHadoopParamName noSqlParam = (EHadoopParamName) param;
switch(noSqlParam) {
case Server:
noSqlConn.getAttributes().put(INoSQLCommonAttributes.HOST, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case ConnectionString:
noSqlConn.getAttributes().put(IMongoDBAttributes.CONN_STRING, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case Port:
noSqlConn.getAttributes().put(INoSQLCommonAttributes.PORT, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case Database:
noSqlConn.getAttributes().put(INoSQLCommonAttributes.DATABASE, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case Keyspace:
noSqlConn.getAttributes().put(INoSQLCommonAttributes.DATABASE, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case Databasepath:
noSqlConn.getAttributes().put(INeo4jAttributes.DATABASE_PATH, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case ServerUrl:
noSqlConn.getAttributes().put(INeo4jAttributes.SERVER_URL, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case UserName:
noSqlConn.getAttributes().put(INoSQLCommonAttributes.USERNAME, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case Password:
noSqlConn.getAttributes().put(INoSQLCommonAttributes.PASSWORD, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case Keystore:
noSqlConn.getAttributes().put(IMongoDBAttributes.X509_CERT, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case KeystorePass:
noSqlConn.getAttributes().put(IMongoDBAttributes.X509_CERT_KEYSTORE_PASSWORD, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case Truststore:
noSqlConn.getAttributes().put(IMongoDBAttributes.X509_CERT_AUTH, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case TruststorePass:
noSqlConn.getAttributes().put(IMongoDBAttributes.X509_CERT_AUTH_TRUSTSTORE_PASSWORD, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case AuthenticationDatabase:
noSqlConn.getAttributes().put(IMongoDBAttributes.AUTHENTICATION_DATABASE, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case UserPrincipal:
noSqlConn.getAttributes().put(IMongoDBAttributes.KRB_USER_PRINCIPAL, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case Realm:
noSqlConn.getAttributes().put(IMongoDBAttributes.KRB_REALM, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case KDCServer:
noSqlConn.getAttributes().put(IMongoDBAttributes.KRB_KDC, ContextParameterUtils.getNewScriptCode(noSqlVariableName, LANGUAGE));
break;
case ReplicaSets:
String replicaSets = noSqlConn.getAttributes().get(IMongoDBAttributes.REPLICA_SET);
try {
JSONArray jsa = new JSONArray(replicaSets);
for (int i = 0; i < jsa.length(); i++) {
JSONObject jso = jsa.getJSONObject(i);
int paramNum = i + 1;
String hostParamName = noSqlVariableName + ExtendedNodeConnectionContextUtils.getReplicaParamName(EHadoopParamName.ReplicaHost, paramNum);
String portParamName = noSqlVariableName + ExtendedNodeConnectionContextUtils.getReplicaParamName(EHadoopParamName.ReplicaPort, paramNum);
jso.put(IMongoConstants.REPLICA_HOST_KEY, ContextParameterUtils.getNewScriptCode(hostParamName, LANGUAGE));
jso.put(IMongoConstants.REPLICA_PORT_KEY, ContextParameterUtils.getNewScriptCode(portParamName, LANGUAGE));
}
noSqlConn.getAttributes().put(IMongoDBAttributes.REPLICA_SET, jsa.toString());
} catch (JSONException e) {
ExceptionHandler.process(e);
}
break;
default:
}
}
use of org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName in project tbd-studio-se by Talend.
the class NoSQLRepositoryContextHandler method setPropertiesForExistContextMode.
@Override
public void setPropertiesForExistContextMode(Connection connection, Set<IConnParamName> paramSet, Map<ContextItem, List<ConectionAdaptContextVariableModel>> adaptMap) {
if (connection == null) {
return;
}
if (connection instanceof NoSQLConnection) {
NoSQLConnection noSqlConn = (NoSQLConnection) connection;
ContextItem currentContext = null;
for (IConnParamName param : paramSet) {
if (param instanceof EHadoopParamName) {
String noSqlVariableName = null;
EHadoopParamName noSqlParam = (EHadoopParamName) param;
if (noSqlParam == EHadoopParamName.ReplicaSets) {
String replicaSets = noSqlConn.getAttributes().get(IMongoDBAttributes.REPLICA_SET);
try {
JSONArray jsa = new JSONArray(replicaSets);
for (int i = 0; i < jsa.length(); i++) {
JSONObject jso = jsa.getJSONObject(i);
int paramNum = i + 1;
String hostParamName = ExtendedNodeConnectionContextUtils.getReplicaParamName(EHadoopParamName.ReplicaHost, paramNum);
String portParamName = ExtendedNodeConnectionContextUtils.getReplicaParamName(EHadoopParamName.ReplicaPort, paramNum);
String hostVariableName = null;
String portVariableName = null;
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(hostParamName)) {
hostVariableName = model.getName();
} else if (model.getValue().equals(portParamName)) {
portVariableName = model.getName();
}
if (hostVariableName != null && portVariableName != null) {
break;
}
}
}
}
if (hostVariableName != null && portVariableName != null) {
hostVariableName = getCorrectVariableName(currentContext, hostVariableName, hostParamName);
portVariableName = getCorrectVariableName(currentContext, portVariableName, portParamName);
jso.put(IMongoConstants.REPLICA_HOST_KEY, ContextParameterUtils.getNewScriptCode(hostVariableName, LANGUAGE));
jso.put(IMongoConstants.REPLICA_PORT_KEY, ContextParameterUtils.getNewScriptCode(portVariableName, LANGUAGE));
}
}
noSqlConn.getAttributes().put(IMongoDBAttributes.REPLICA_SET, jsa.toString());
} catch (JSONException e) {
ExceptionHandler.process(e);
}
} else {
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(noSqlParam.name())) {
noSqlVariableName = model.getName();
break;
}
}
}
}
if (noSqlVariableName != null) {
noSqlVariableName = getCorrectVariableName(currentContext, noSqlVariableName, noSqlParam);
matchContextForAttribues(noSqlConn, noSqlParam, noSqlVariableName);
}
}
}
}
}
}
Aggregations