Search in sources :

Example 1 with HDFSConnection

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;
}
Also used : HDFSConnection(org.talend.repository.model.hdfs.HDFSConnection) Map(java.util.Map)

Example 2 with HDFSConnection

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;
}
Also used : HDFSConnection(org.talend.repository.model.hdfs.HDFSConnection) Property(org.talend.core.model.properties.Property) HDFSConnectionItem(org.talend.repository.model.hdfs.HDFSConnectionItem)

Example 3 with HDFSConnection

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));
    }
}
Also used : EHadoopParamName(org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName) HDFSConnection(org.talend.repository.model.hdfs.HDFSConnection) IConnParamName(org.talend.metadata.managment.ui.model.IConnParamName) Map(java.util.Map)

Example 4 with HDFSConnection

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;
}
Also used : HDFSConnection(org.talend.repository.model.hdfs.HDFSConnection) HashSet(java.util.HashSet)

Example 5 with HDFSConnection

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:
    }
}
Also used : EHadoopParamName(org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName) HDFSConnection(org.talend.repository.model.hdfs.HDFSConnection)

Aggregations

HDFSConnection (org.talend.repository.model.hdfs.HDFSConnection)16 ArrayList (java.util.ArrayList)6 Map (java.util.Map)5 IConnParamName (org.talend.metadata.managment.ui.model.IConnParamName)4 EHadoopParamName (org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName)4 HashSet (java.util.HashSet)2 List (java.util.List)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 IContextParameter (org.talend.core.model.process.IContextParameter)2 ContextItem (org.talend.core.model.properties.ContextItem)2 Property (org.talend.core.model.properties.Property)2 ConectionAdaptContextVariableModel (org.talend.core.ui.context.model.table.ConectionAdaptContextVariableModel)2 HDFSConnectionBean (org.talend.designer.hdfsbrowse.model.HDFSConnectionBean)2 HDFSConnectionItem (org.talend.repository.model.hdfs.HDFSConnectionItem)2 Test (org.junit.Test)1 EHadoopVersion4Drivers (org.talend.core.hadoop.version.EHadoopVersion4Drivers)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 HDFSFile (org.talend.designer.hdfsbrowse.model.HDFSFile)1 HadoopClusterConnection (org.talend.repository.model.hadoopcluster.HadoopClusterConnection)1