Search in sources :

Example 6 with HadoopSubConnectionItem

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

Example 7 with HadoopSubConnectionItem

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);
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopSubConnection(org.talend.repository.model.hadoopcluster.HadoopSubConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 8 with HadoopSubConnectionItem

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;
}
Also used : DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) HadoopSubConnection(org.talend.repository.model.hadoopcluster.HadoopSubConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopSubConnection(org.talend.repository.model.hadoopcluster.HadoopSubConnection) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem)

Aggregations

HadoopSubConnectionItem (org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem)8 HadoopSubConnection (org.talend.repository.model.hadoopcluster.HadoopSubConnection)4 HadoopClusterConnection (org.talend.repository.model.hadoopcluster.HadoopClusterConnection)3 HadoopClusterConnectionItem (org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)3 ArrayList (java.util.ArrayList)2 Connection (org.talend.core.model.metadata.builder.connection.Connection)2 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)2 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)2 Item (org.talend.core.model.properties.Item)2 Property (org.talend.core.model.properties.Property)2 PersistenceException (org.talend.commons.exception.PersistenceException)1 IHadoopClusterService (org.talend.core.hadoop.IHadoopClusterService)1 ConnectionItem (org.talend.core.model.properties.ConnectionItem)1 ContextItem (org.talend.core.model.properties.ContextItem)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 ImportItem (org.talend.repository.items.importexport.handlers.model.ImportItem)1 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1 IRepositoryNode (org.talend.repository.model.IRepositoryNode)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1