Search in sources :

Example 1 with HCatalogConnection

use of org.talend.repository.model.hcatalog.HCatalogConnection in project tbd-studio-se by Talend.

the class HCatalogContextHandler method setPropertiesForContextMode.

@Override
public void setPropertiesForContextMode(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
    if (connection == null) {
        return;
    }
    if (connection instanceof HCatalogConnection) {
        HCatalogConnection conn = (HCatalogConnection) connection;
        String originalVariableName = prefixName + ConnectionContextHelper.LINE;
        String hadoopVariableName = null;
        for (IConnParamName param : paramSet) {
            if (param instanceof EHadoopParamName) {
                EHadoopParamName hcatalogConnectionParam = (EHadoopParamName) param;
                originalVariableName = prefixName + ConnectionContextHelper.LINE;
                hadoopVariableName = originalVariableName + hcatalogConnectionParam;
                matchContextForAttribues(conn, hcatalogConnectionParam, hadoopVariableName);
            }
        }
        String hadoopProperties = conn.getHadoopProperties();
        List<Map<String, Object>> propertiesAfterContext = transformHadoopPropertiesForContextMode(HadoopRepositoryUtil.getHadoopPropertiesList(hadoopProperties), prefixName);
        conn.setHadoopProperties(HadoopRepositoryUtil.getHadoopPropertiesJsonStr(propertiesAfterContext));
    }
}
Also used : HCatalogConnection(org.talend.repository.model.hcatalog.HCatalogConnection) EHadoopParamName(org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName) IConnParamName(org.talend.metadata.managment.ui.model.IConnParamName) Map(java.util.Map)

Example 2 with HCatalogConnection

use of org.talend.repository.model.hcatalog.HCatalogConnection in project tbd-studio-se by Talend.

the class HCatalogContextHandler method setPropertiesForExistContextMode.

@Override
public void setPropertiesForExistContextMode(Connection connection, Set<IConnParamName> paramSet, Map<ContextItem, List<ConectionAdaptContextVariableModel>> adaptMap) {
    if (connection == null) {
        return;
    }
    if (connection instanceof HCatalogConnection) {
        HCatalogConnection hcatalogConn = (HCatalogConnection) connection;
        ContextItem currentContext = null;
        for (IConnParamName param : paramSet) {
            if (param instanceof EHadoopParamName) {
                String hcatalogVariableName = null;
                EHadoopParamName hcatalogParam = (EHadoopParamName) 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(hcatalogParam.name())) {
                                hcatalogVariableName = model.getName();
                                break;
                            }
                        }
                    }
                }
                if (hcatalogVariableName != null) {
                    hcatalogVariableName = getCorrectVariableName(currentContext, hcatalogVariableName, hcatalogParam);
                    matchContextForAttribues(hcatalogConn, hcatalogParam, hcatalogVariableName);
                }
            }
        }
        matchAdditionProperties(hcatalogConn, adaptMap);
    }
}
Also used : HCatalogConnection(org.talend.repository.model.hcatalog.HCatalogConnection) ContextItem(org.talend.core.model.properties.ContextItem) EHadoopParamName(org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName) IConnParamName(org.talend.metadata.managment.ui.model.IConnParamName) ArrayList(java.util.ArrayList) List(java.util.List) ConectionAdaptContextVariableModel(org.talend.core.ui.context.model.table.ConectionAdaptContextVariableModel) Map(java.util.Map)

Example 3 with HCatalogConnection

use of org.talend.repository.model.hcatalog.HCatalogConnection in project tbd-studio-se by Talend.

the class HCatalogContextHandler method getConAdditionPropertiesForContextMode.

@Override
public Set<String> getConAdditionPropertiesForContextMode(Connection conn) {
    Set<String> conVarList = new HashSet<String>();
    if (conn instanceof HCatalogConnection) {
        HCatalogConnection hcatalogConn = (HCatalogConnection) conn;
        conVarList = getConAdditionProperties(HadoopRepositoryUtil.getHadoopPropertiesList(hcatalogConn.getHadoopProperties()));
    }
    return conVarList;
}
Also used : HCatalogConnection(org.talend.repository.model.hcatalog.HCatalogConnection) HashSet(java.util.HashSet)

Example 4 with HCatalogConnection

use of org.talend.repository.model.hcatalog.HCatalogConnection in project tbd-studio-se by Talend.

the class HCatalogConnectionCreator method create.

@Override
public ConnectionItem create(Map<String, Map<String, String>> initParams) throws CoreException {
    HCatalogConnection connection = HCatalogFactory.eINSTANCE.createHCatalogConnection();
    Property connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
    setPropertyParameters(connectionProperty);
    initializeConnectionParameters(connection);
    HadoopSubConnectionItem connectionItem = HCatalogFactory.eINSTANCE.createHCatalogConnectionItem();
    connectionItem.setProperty(connectionProperty);
    connectionItem.setConnection(connection);
    setParameters(connection, initParams);
    appendToHadoopCluster(connectionItem);
    return connectionItem;
}
Also used : HCatalogConnection(org.talend.repository.model.hcatalog.HCatalogConnection) Property(org.talend.core.model.properties.Property) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem)

Example 5 with HCatalogConnection

use of org.talend.repository.model.hcatalog.HCatalogConnection in project tbd-studio-se by Talend.

the class HCatalogContextHandler method matchContextForAttribues.

@Override
protected void matchContextForAttribues(Connection conn, IConnParamName paramName, String hcatalogVariableName) {
    HCatalogConnection hcatalogConn = (HCatalogConnection) conn;
    EHadoopParamName hcatalogParam = (EHadoopParamName) paramName;
    switch(hcatalogParam) {
        case HCatalogHostName:
            hcatalogConn.setHostName(ContextParameterUtils.getNewScriptCode(hcatalogVariableName, LANGUAGE));
            break;
        case HCatalogPort:
            hcatalogConn.setPort(ContextParameterUtils.getNewScriptCode(hcatalogVariableName, LANGUAGE));
            break;
        case HCatalogUser:
            hcatalogConn.setUserName(ContextParameterUtils.getNewScriptCode(hcatalogVariableName, LANGUAGE));
            break;
        case HCatalogPassword:
            hcatalogConn.setPassword(ContextParameterUtils.getNewScriptCode(hcatalogVariableName, LANGUAGE));
            break;
        case HCatalogKerPrin:
            hcatalogConn.setKrbPrincipal(ContextParameterUtils.getNewScriptCode(hcatalogVariableName, LANGUAGE));
            break;
        case HCatalogRealm:
            hcatalogConn.setKrbRealm(ContextParameterUtils.getNewScriptCode(hcatalogVariableName, LANGUAGE));
            break;
        case HCatalogDatabase:
            hcatalogConn.setDatabase(ContextParameterUtils.getNewScriptCode(hcatalogVariableName, LANGUAGE));
            break;
        case HcataLogRowSeparator:
            hcatalogConn.setRowSeparator(ContextParameterUtils.getNewScriptCode(hcatalogVariableName, LANGUAGE));
            break;
        case HcatalogFileSeparator:
            hcatalogConn.setFieldSeparator(ContextParameterUtils.getNewScriptCode(hcatalogVariableName, LANGUAGE));
            break;
        default:
    }
}
Also used : HCatalogConnection(org.talend.repository.model.hcatalog.HCatalogConnection) EHadoopParamName(org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName)

Aggregations

HCatalogConnection (org.talend.repository.model.hcatalog.HCatalogConnection)14 Map (java.util.Map)5 ArrayList (java.util.ArrayList)4 EHadoopParamName (org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName)4 IConnParamName (org.talend.metadata.managment.ui.model.IConnParamName)3 List (java.util.List)2 ContextItem (org.talend.core.model.properties.ContextItem)2 ConectionAdaptContextVariableModel (org.talend.core.ui.context.model.table.ConectionAdaptContextVariableModel)2 HashSet (java.util.HashSet)1 EHadoopVersion4Drivers (org.talend.core.hadoop.version.EHadoopVersion4Drivers)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 IContextParameter (org.talend.core.model.process.IContextParameter)1 Property (org.talend.core.model.properties.Property)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 TdTable (org.talend.cwm.relational.TdTable)1 HCatalogNode (org.talend.repository.hcatalog.model.HCatalogNode)1 IHCatalogNode (org.talend.repository.hcatalog.model.IHCatalogNode)1 HadoopSubConnectionItem (org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem)1 HCatalogConnectionItem (org.talend.repository.model.hcatalog.HCatalogConnectionItem)1