use of org.talend.repository.model.hdfs.HDFSConnection in project tbd-studio-se by Talend.
the class HdfsContextUpdateService method updateContextParameter.
@Override
public boolean updateContextParameter(Connection conn, String oldValue, String newValue) {
boolean isModified = false;
if (conn.isContextMode()) {
if (conn instanceof HDFSConnection) {
HDFSConnection hdfsConn = (HDFSConnection) conn;
if (hdfsConn.getUserName() != null && hdfsConn.getUserName().equals(oldValue)) {
hdfsConn.setUserName(newValue);
isModified = true;
} else if (hdfsConn.getRowSeparator() != null && hdfsConn.getRowSeparator().equals(oldValue)) {
hdfsConn.setRowSeparator(newValue);
isModified = true;
} else if (hdfsConn.getHeaderValue() != null && hdfsConn.getHeaderValue().equals(oldValue)) {
hdfsConn.setHeaderValue(newValue);
isModified = true;
} else {
List<Map<String, Object>> hadoopProperties = HadoopRepositoryUtil.getHadoopPropertiesList(hdfsConn.getHadoopProperties());
String finalProperties = updateHadoopProperties(hadoopProperties, oldValue, newValue);
if (finalProperties != null) {
hdfsConn.setHadoopProperties(updateHadoopProperties(hadoopProperties, oldValue, newValue));
isModified = true;
}
}
}
}
return isModified;
}
use of org.talend.repository.model.hdfs.HDFSConnection in project tbd-studio-se by Talend.
the class HDFSConnectionTestUtils method createHDFSItem.
public static HDFSConnectionItem createHDFSItem(String id, String name) {
HDFSConnection connection = HDFSFactory.eINSTANCE.createHDFSConnection();
// $NON-NLS-1$
connection.setRowSeparator("\\n");
// $NON-NLS-1$
connection.setFieldSeparator(";");
// $NON-NLS-1$
connection.setHeaderValue("2");
Property connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
connectionProperty.setAuthor(((RepositoryContext) CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
// $NON-NLS-1$
connectionProperty.setStatusCode("");
connectionProperty.setId(id);
connectionProperty.setLabel(name);
HDFSConnectionItem connectionItem = HDFSFactory.eINSTANCE.createHDFSConnectionItem();
connectionItem.setProperty(connectionProperty);
connectionItem.setConnection(connection);
return connectionItem;
}
use of org.talend.repository.model.hdfs.HDFSConnection in project tbd-studio-se by Talend.
the class HdfsContextHandler method setPropertiesForContextMode.
@Override
public void setPropertiesForContextMode(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
if (connection == null) {
return;
}
if (connection instanceof HDFSConnection) {
HDFSConnection hdfsConn = (HDFSConnection) connection;
String originalVariableName = prefixName + ConnectionContextHelper.LINE;
String hdfsVariableName = null;
for (IConnParamName param : paramSet) {
if (param instanceof EHadoopParamName) {
EHadoopParamName hdfsConnectionParam = (EHadoopParamName) param;
originalVariableName = prefixName + ConnectionContextHelper.LINE;
hdfsVariableName = originalVariableName + hdfsConnectionParam;
matchContextForAttribues(hdfsConn, hdfsConnectionParam, hdfsVariableName);
}
}
String hadoopProperties = hdfsConn.getHadoopProperties();
List<Map<String, Object>> propertiesAfterContext = transformHadoopPropertiesForContextMode(HadoopRepositoryUtil.getHadoopPropertiesList(hadoopProperties), prefixName);
hdfsConn.setHadoopProperties(HadoopRepositoryUtil.getHadoopPropertiesJsonStr(propertiesAfterContext));
}
}
use of org.talend.repository.model.hdfs.HDFSConnection in project tbd-studio-se by Talend.
the class HdfsContextHandler method getConAdditionPropertiesForContextMode.
@Override
public Set<String> getConAdditionPropertiesForContextMode(Connection conn) {
Set<String> conVarList = new HashSet<String>();
if (conn instanceof HDFSConnection) {
HDFSConnection hdfsConn = (HDFSConnection) conn;
conVarList = getConAdditionProperties(HadoopRepositoryUtil.getHadoopPropertiesList(hdfsConn.getHadoopProperties()));
}
return conVarList;
}
use of org.talend.repository.model.hdfs.HDFSConnection in project tbd-studio-se by Talend.
the class HdfsContextHandler method matchContextForAttribues.
@Override
protected void matchContextForAttribues(Connection conn, IConnParamName paramName, String hdfsVariableName) {
HDFSConnection hdfsConn = (HDFSConnection) conn;
EHadoopParamName hdfsParam = (EHadoopParamName) paramName;
switch(hdfsParam) {
case HdfsUser:
hdfsConn.setUserName(ContextParameterUtils.getNewScriptCode(hdfsVariableName, LANGUAGE));
break;
case HdfsRowSeparator:
hdfsConn.setRowSeparator(ContextParameterUtils.getNewScriptCode(hdfsVariableName, LANGUAGE));
break;
case HdfsFileSeparator:
hdfsConn.setFieldSeparator(ContextParameterUtils.getNewScriptCode(hdfsVariableName, LANGUAGE));
break;
case HdfsRowHeader:
hdfsConn.setHeaderValue(ContextParameterUtils.getNewScriptCode(hdfsVariableName, LANGUAGE));
break;
default:
}
}
Aggregations