Search in sources :

Example 1 with HadoopSubConnection

use of org.talend.repository.model.hadoopcluster.HadoopSubConnection in project tbd-studio-se by Talend.

the class AbstractHadoopSubnodeRepositoryContentHandler method addNode.

@Override
public void addNode(Project project, RepositoryNode parentNode) {
    IRepositoryViewObject parentObject = parentNode.getObject();
    if (parentObject == null) {
        return;
    }
    if (project == null) {
        project = ProjectManager.getInstance().getCurrentProject();
    }
    String clusterId = parentObject.getProperty().getId();
    ERepositoryObjectType objectType = getProcessType();
    List<HadoopSubConnectionItem> items = new ArrayList<HadoopSubConnectionItem>();
    try {
        List<IRepositoryViewObject> repObjs = ProxyRepositoryFactory.getInstance().getAll(project, objectType);
        for (IRepositoryViewObject repObj : repObjs) {
            if (repObj != null && repObj.getProperty() != null) {
                HadoopSubConnectionItem item = (HadoopSubConnectionItem) repObj.getProperty().getItem();
                HadoopSubConnection connection = (HadoopSubConnection) item.getConnection();
                if (!items.contains(item) && connection.getRelativeHadoopClusterId().equals(clusterId)) {
                    items.add(item);
                }
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    if (items.size() == 0) {
        return;
    }
    RepositoryNode typeFolderNode = createHadoopFolderNode(parentNode, objectType, objectType.getLabel(), items.size());
    parentNode.getChildren().add(typeFolderNode);
    for (HadoopSubConnectionItem item : items) {
        createHadoopSubNode(typeFolderNode, item);
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ArrayList(java.util.ArrayList) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) HadoopSubConnection(org.talend.repository.model.hadoopcluster.HadoopSubConnection) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem)

Example 2 with HadoopSubConnection

use of org.talend.repository.model.hadoopcluster.HadoopSubConnection in project tbd-studio-se by Talend.

the class AbstractHadoopSubConnectionCreator method appendToHadoopCluster.

protected void appendToHadoopCluster(HadoopSubConnectionItem connectionItem) {
    HadoopSubConnection connection = (HadoopSubConnection) connectionItem.getConnection();
    HadoopClusterConnection hcConnection = (HadoopClusterConnection) ((HadoopClusterConnectionItem) relativeHadoopClusterItem).getConnection();
    if (hcConnection != null) {
        connection.setRelativeHadoopClusterId(relativeHadoopClusterId);
        hcConnection.getConnectionList().add(connectionItem.getProperty().getId());
    }
}
Also used : HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopSubConnection(org.talend.repository.model.hadoopcluster.HadoopSubConnection)

Example 3 with HadoopSubConnection

use of org.talend.repository.model.hadoopcluster.HadoopSubConnection in project tbd-studio-se by Talend.

the class AbstractHadoopClusterMigrationTask method convert.

protected void convert(ConnectionItem item) throws Exception {
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    Connection connection = item.getConnection();
    if (connection instanceof HadoopSubConnection) {
        HadoopSubConnection hadoopSubConnection = (HadoopSubConnection) connection;
        String relClusterId = hadoopSubConnection.getRelativeHadoopClusterId();
        if (StringUtils.isNotBlank(relClusterId)) {
            modified[0] = false;
            return;
        } else {
            modified[0] = true;
        }
        HadoopClusterConnection hcConn = null;
        HadoopClusterConnectionItem hcConnItem = null;
        String migratedHCName = getClusterName(hadoopSubConnection);
        List<IRepositoryViewObject> hcRepObjs = factory.getAll(HadoopClusterRepositoryNodeType.HADOOPCLUSTER);
        for (IRepositoryViewObject repObj : hcRepObjs) {
            if (repObj != null && repObj.getProperty() != null && migratedHCName.equals(repObj.getProperty().getLabel())) {
                hcConnItem = (HadoopClusterConnectionItem) repObj.getProperty().getItem();
                break;
            }
        }
        if (hcConnItem == null) {
            hcConn = HadoopClusterFactory.eINSTANCE.createHadoopClusterConnection();
            Property connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
            connectionProperty.setAuthor(((RepositoryContext) CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
            connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
            // $NON-NLS-1$
            connectionProperty.setStatusCode("");
            hcConnItem = HadoopClusterFactory.eINSTANCE.createHadoopClusterConnectionItem();
            hcConnItem.setProperty(connectionProperty);
            hcConnItem.setConnection(hcConn);
            connectionProperty.setLabel(migratedHCName);
            hcConn.setName(migratedHCName);
            hcConn.setLabel(migratedHCName);
            String nextId = factory.getNextId();
            connectionProperty.setId(nextId);
            // $NON-NLS-1$
            factory.create(hcConnItem, new Path(""));
        }
        if (hcConn == null) {
            hcConn = (HadoopClusterConnection) hcConnItem.getConnection();
        }
        initCluster(hcConn, hadoopSubConnection);
        factory.save(hcConnItem);
        if (hcConnItem != null) {
            hadoopSubConnection.setRelativeHadoopClusterId(hcConnItem.getProperty().getId());
            factory.save(item);
            HCRepositoryUtil.setupConnectionToHadoopCluster(hcConnItem, item.getProperty().getId());
        }
    }
}
Also used : Path(org.eclipse.core.runtime.Path) HadoopSubConnection(org.talend.repository.model.hadoopcluster.HadoopSubConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopSubConnection(org.talend.repository.model.hadoopcluster.HadoopSubConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 4 with HadoopSubConnection

use of org.talend.repository.model.hadoopcluster.HadoopSubConnection in project tbd-studio-se by Talend.

the class AbstractHadoopSubnodeRepositoryContentHandler method getRelativeHadoopClusterItemId.

@Override
public String getRelativeHadoopClusterItemId(Item item) {
    if (isProcess(item) && item instanceof HadoopSubConnectionItem) {
        HadoopSubConnectionItem hadoopSubConnectionItem = (HadoopSubConnectionItem) item;
        Connection connection = hadoopSubConnectionItem.getConnection();
        if (connection instanceof HadoopSubConnection) {
            return ((HadoopSubConnection) connection).getRelativeHadoopClusterId();
        }
    }
    return null;
}
Also used : HadoopSubConnection(org.talend.repository.model.hadoopcluster.HadoopSubConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) HadoopSubConnection(org.talend.repository.model.hadoopcluster.HadoopSubConnection) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem)

Example 5 with HadoopSubConnection

use of org.talend.repository.model.hadoopcluster.HadoopSubConnection 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

HadoopSubConnection (org.talend.repository.model.hadoopcluster.HadoopSubConnection)6 HadoopClusterConnection (org.talend.repository.model.hadoopcluster.HadoopClusterConnection)4 HadoopSubConnectionItem (org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem)4 Connection (org.talend.core.model.metadata.builder.connection.Connection)3 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)2 HadoopClusterConnectionItem (org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)2 ArrayList (java.util.ArrayList)1 Path (org.eclipse.core.runtime.Path)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 ConnectionItem (org.talend.core.model.properties.ConnectionItem)1 ContextItem (org.talend.core.model.properties.ContextItem)1 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)1 Item (org.talend.core.model.properties.Item)1 Property (org.talend.core.model.properties.Property)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 IRepositoryNode (org.talend.repository.model.IRepositoryNode)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1