Search in sources :

Example 6 with HCatalogConnection

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

the class TableSelectorTreeViewerProvider method getChildren.

@Override
public Object[] getChildren(Object parentElement) {
    List<IHCatalogNode> nodes = new ArrayList<IHCatalogNode>();
    if (parentElement instanceof HCatalogConnection) {
        try {
            List<TdTable> tables = ExtractMetaDataFromHCatalog.extractTables((HCatalogConnection) parentElement);
            for (TdTable table : tables) {
                IHCatalogNode node = new HCatalogNode();
                node.setValue(table.getLabel());
                node.setTable(table);
                nodes.add(node);
            }
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
    return nodes.toArray();
}
Also used : HCatalogConnection(org.talend.repository.model.hcatalog.HCatalogConnection) TdTable(org.talend.cwm.relational.TdTable) IHCatalogNode(org.talend.repository.hcatalog.model.IHCatalogNode) HCatalogNode(org.talend.repository.hcatalog.model.HCatalogNode) ArrayList(java.util.ArrayList) IHCatalogNode(org.talend.repository.hcatalog.model.IHCatalogNode)

Example 7 with HCatalogConnection

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

the class HCatalogContextHandler method createContextParameters.

@Override
public List<IContextParameter> createContextParameters(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
    List<IContextParameter> varList = new ArrayList<IContextParameter>();
    if (connection instanceof HCatalogConnection) {
        HCatalogConnection conn = (HCatalogConnection) connection;
        String paramPrefix = prefixName + ConnectionContextHelper.LINE;
        String paramName = null;
        for (IConnParamName param : paramSet) {
            if (param instanceof EHadoopParamName) {
                EHadoopParamName hcatalogParam = (EHadoopParamName) param;
                paramName = paramPrefix + hcatalogParam;
                switch(hcatalogParam) {
                    case HCatalogHostName:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getHostName());
                        break;
                    case HCatalogPort:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getPort());
                        break;
                    case HCatalogUser:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getUserName());
                        break;
                    case HCatalogPassword:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getPassword(), JavaTypesManager.PASSWORD);
                        break;
                    case HCatalogKerPrin:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getKrbPrincipal());
                        break;
                    case HCatalogRealm:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getKrbRealm());
                        break;
                    case HCatalogDatabase:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getDatabase());
                        break;
                    case HcataLogRowSeparator:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getRowSeparator());
                        break;
                    case HcatalogFileSeparator:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getFieldSeparator());
                        break;
                    default:
                }
            }
        }
        createHadoopPropertiesContextVariable(prefixName, varList, conn.getHadoopProperties());
    }
    return varList;
}
Also used : HCatalogConnection(org.talend.repository.model.hcatalog.HCatalogConnection) ArrayList(java.util.ArrayList) EHadoopParamName(org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName) IConnParamName(org.talend.metadata.managment.ui.model.IConnParamName) IContextParameter(org.talend.core.model.process.IContextParameter)

Example 8 with HCatalogConnection

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

the class HCatalogContextUpdateService method updateContextParameter.

@Override
public boolean updateContextParameter(Connection conn, String oldValue, String newValue) {
    boolean isModified = false;
    if (conn.isContextMode()) {
        if (conn instanceof HCatalogConnection) {
            HCatalogConnection hcatalogConn = (HCatalogConnection) conn;
            if (hcatalogConn.getHostName() != null && hcatalogConn.getHostName().equals(oldValue)) {
                hcatalogConn.setHostName(newValue);
                isModified = true;
            } else if (hcatalogConn.getPort() != null && hcatalogConn.getPort().equals(oldValue)) {
                hcatalogConn.setPort(newValue);
                isModified = true;
            } else if (hcatalogConn.getUserName() != null && hcatalogConn.getUserName().equals(oldValue)) {
                hcatalogConn.setUserName(newValue);
                isModified = true;
            } else if (hcatalogConn.getPassword() != null && hcatalogConn.getPassword().equals(oldValue)) {
                hcatalogConn.setPassword(newValue);
                isModified = true;
            } else if (hcatalogConn.getKrbPrincipal() != null && hcatalogConn.getKrbPrincipal().equals(oldValue)) {
                hcatalogConn.setKrbPrincipal(newValue);
                isModified = true;
            } else if (hcatalogConn.getKrbRealm() != null && hcatalogConn.getKrbRealm().equals(oldValue)) {
                hcatalogConn.setKrbRealm(newValue);
                isModified = true;
            } else if (hcatalogConn.getDatabase() != null && hcatalogConn.getDatabase().equals(oldValue)) {
                hcatalogConn.setDatabase(newValue);
                isModified = true;
            } else if (hcatalogConn.getRowSeparator() != null && hcatalogConn.getRowSeparator().equals(oldValue)) {
                hcatalogConn.setRowSeparator(newValue);
                isModified = true;
            } else if (hcatalogConn.getFieldSeparator() != null && hcatalogConn.getFieldSeparator().equals(oldValue)) {
                hcatalogConn.setFieldSeparator(newValue);
                isModified = true;
            } else {
                List<Map<String, Object>> hadoopProperties = HadoopRepositoryUtil.getHadoopPropertiesList(hcatalogConn.getHadoopProperties());
                String finalProperties = updateHadoopProperties(hadoopProperties, oldValue, newValue);
                if (finalProperties != null) {
                    hcatalogConn.setHadoopProperties(updateHadoopProperties(hadoopProperties, oldValue, newValue));
                    isModified = true;
                }
            }
        }
    }
    return isModified;
}
Also used : HCatalogConnection(org.talend.repository.model.hcatalog.HCatalogConnection) Map(java.util.Map)

Example 9 with HCatalogConnection

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

the class HCatalogConnectionCreator method initializeConnectionParameters.

@Override
protected void initializeConnectionParameters(Connection conn) {
    if (!(conn instanceof HCatalogConnection)) {
        return;
    }
    HCatalogConnection connection = (HCatalogConnection) conn;
    connection.setRowSeparator(IExtractSchemaService.DEFAULT_ROW_SEPARATOR);
    connection.setFieldSeparator(IExtractSchemaService.DEFAULT_FIELD_SEPARATOR);
}
Also used : HCatalogConnection(org.talend.repository.model.hcatalog.HCatalogConnection)

Example 10 with HCatalogConnection

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

the class CreateHCatalogSchemaAction method doRun.

@Override
protected void doRun() {
    if (repositoryNode == null) {
        repositoryNode = getCurrentRepositoryNode();
    }
    HCatalogConnection connection = null;
    MetadataTable metadataTable = null;
    boolean creation = false;
    if (repositoryNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
        ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
        String metadataTableLabel = (String) repositoryNode.getProperties(EProperties.LABEL);
        HCatalogConnectionItem item = null;
        if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
            item = (HCatalogConnectionItem) repositoryNode.getObject().getProperty().getItem();
            connection = (HCatalogConnection) item.getConnection();
            metadataTable = TableHelper.findByLabel(connection, metadataTableLabel);
            creation = false;
        } else if (nodeType == HCatalogRepositoryNodeType.HCATALOG) {
            item = (HCatalogConnectionItem) repositoryNode.getObject().getProperty().getItem();
            connection = (HCatalogConnection) item.getConnection();
            creation = true;
        } else {
            return;
        }
        boolean isOK = true;
        if (creation) {
            isOK = checkHCatalogConnection((HCatalogConnection) item.getConnection());
        }
        if (isOK) {
            openHCatalogSchemaWizard(item, metadataTable, false, creation);
        }
    }
}
Also used : HCatalogConnection(org.talend.repository.model.hcatalog.HCatalogConnection) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) HCatalogConnectionItem(org.talend.repository.model.hcatalog.HCatalogConnectionItem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

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