use of org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem in project tbd-studio-se by Talend.
the class HDFSConnectionCreator method create.
@Override
public ConnectionItem create(Map<String, Map<String, String>> initParams) throws CoreException {
HDFSConnection connection = HDFSFactory.eINSTANCE.createHDFSConnection();
Property connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
setPropertyParameters(connectionProperty);
initializeConnectionParameters(connection);
HadoopSubConnectionItem connectionItem = HDFSFactory.eINSTANCE.createHDFSConnectionItem();
connectionItem.setProperty(connectionProperty);
connectionItem.setConnection(connection);
appendToHadoopCluster(connectionItem);
return connectionItem;
}
use of org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem in project tbd-studio-se by Talend.
the class HadoopClusterService method copyHadoopCluster.
@Override
public void copyHadoopCluster(final Item sourceItem, final IPath path, String newName) throws PersistenceException, BusinessException {
if (isHadoopClusterItem(sourceItem)) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
HadoopClusterConnectionItem sourceClusterItem = (HadoopClusterConnectionItem) sourceItem;
HadoopClusterConnectionItem targetClusterItem = null;
if (StringUtils.isNotBlank(newName)) {
targetClusterItem = (HadoopClusterConnectionItem) factory.copy(sourceClusterItem, path, newName);
} else {
targetClusterItem = (HadoopClusterConnectionItem) factory.copy(sourceClusterItem, path, true);
}
HadoopClusterConnection targetClusterConnection = (HadoopClusterConnection) targetClusterItem.getConnection();
targetClusterConnection.getConnectionList().clear();
String targetClusterId = targetClusterItem.getProperty().getId();
Set<Item> sourceSubitems = HCRepositoryUtil.getSubitemsOfHadoopCluster(sourceClusterItem);
for (Item subitem : sourceSubitems) {
Item newSubitem = factory.copy(subitem, path, true);
if (newSubitem instanceof HadoopSubConnectionItem) {
((HadoopSubConnection) ((HadoopSubConnectionItem) newSubitem).getConnection()).setRelativeHadoopClusterId(targetClusterId);
targetClusterConnection.getConnectionList().add(newSubitem.getProperty().getId());
} else if (subitem instanceof DatabaseConnectionItem) {
((DatabaseConnection) ((DatabaseConnectionItem) newSubitem).getConnection()).getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID, targetClusterId);
}
factory.save(newSubitem);
}
factory.save(targetClusterItem);
}
}
use of org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem in project tbd-studio-se by Talend.
the class HadoopClusterService method isValidHadoopSubItem.
@Override
public boolean isValidHadoopSubItem(Item item) {
if (isHadoopSubItem(item)) {
HadoopSubConnectionItem hadoopSubConnectionItem = (HadoopSubConnectionItem) item;
Connection connection = hadoopSubConnectionItem.getConnection();
if (connection instanceof HadoopSubConnection) {
return ((HadoopSubConnection) connection).getRelativeHadoopClusterId() != null;
}
}
return false;
}
Aggregations