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();
}
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;
}
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;
}
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);
}
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);
}
}
}
Aggregations