Search in sources :

Example 1 with HadoopSubConnectionItem

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

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

the class HadoopClusterImportHandler method findRelatedImportItems.

@Override
public List<ImportItem> findRelatedImportItems(IProgressMonitor monitor, ResourcesManager resManager, ImportItem importItem, ImportItem[] allImportItemRecords) throws Exception {
    List<ImportItem> relatedItemRecords = new ArrayList<ImportItem>();
    relatedItemRecords.addAll(super.findRelatedImportItems(monitor, resManager, importItem, allImportItemRecords));
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IHadoopClusterService.class)) {
        IHadoopClusterService hadoopClusterService = (IHadoopClusterService) GlobalServiceRegister.getDefault().getService(IHadoopClusterService.class);
        final Item item = importItem.getItem();
        if (hadoopClusterService != null && hadoopClusterService.isHadoopClusterItem(item)) {
            resolveItem(resManager, importItem);
            HadoopClusterConnection hcConnection = (HadoopClusterConnection) ((HadoopClusterConnectionItem) item).getConnection();
            String clusterId = item.getProperty().getId();
            for (ImportItem ir : allImportItemRecords) {
                resolveItem(resManager, ir);
                Item subItem = ir.getItem();
                String hcId = null;
                if (subItem instanceof HadoopSubConnectionItem) {
                    hcId = ((HadoopSubConnection) ((HadoopSubConnectionItem) subItem).getConnection()).getRelativeHadoopClusterId();
                } else if (subItem instanceof DatabaseConnectionItem) {
                    hcId = ((DatabaseConnection) ((DatabaseConnectionItem) subItem).getConnection()).getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID);
                }
                if (clusterId.equals(hcId)) {
                    if (subItem instanceof HadoopSubConnectionItem) {
                        EList<String> connectionList = hcConnection.getConnectionList();
                        String subItemId = subItem.getProperty().getId();
                        if (!connectionList.contains(subItemId)) {
                            connectionList.add(subItemId);
                        }
                    }
                    relatedItemRecords.add(ir);
                }
            }
        }
    }
    return relatedItemRecords;
}
Also used : ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem) Item(org.talend.core.model.properties.Item) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) IHadoopClusterService(org.talend.core.hadoop.IHadoopClusterService) ArrayList(java.util.ArrayList) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 3 with HadoopSubConnectionItem

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

the class HCatalogConnectionCreator method create.

@Override
public ConnectionItem create(Map<String, Map<String, String>> initParams) throws CoreException {
    HCatalogConnection connection = HCatalogFactory.eINSTANCE.createHCatalogConnection();
    Property connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
    setPropertyParameters(connectionProperty);
    initializeConnectionParameters(connection);
    HadoopSubConnectionItem connectionItem = HCatalogFactory.eINSTANCE.createHCatalogConnectionItem();
    connectionItem.setProperty(connectionProperty);
    connectionItem.setConnection(connection);
    setParameters(connection, initParams);
    appendToHadoopCluster(connectionItem);
    return connectionItem;
}
Also used : HCatalogConnection(org.talend.repository.model.hcatalog.HCatalogConnection) Property(org.talend.core.model.properties.Property) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem)

Example 4 with HadoopSubConnectionItem

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

the class AbstractHadoopSubnodeRepositoryContentHandler method deleteNode.

@Override
protected void deleteNode(Item item) throws Exception {
    if (item instanceof HadoopSubConnectionItem) {
        HadoopSubConnectionItem hadoopSubConnectionItem = (HadoopSubConnectionItem) item;
        HadoopClusterConnectionItem hadoopClusterItem = HCRepositoryUtil.getRelativeHadoopClusterItem(hadoopSubConnectionItem);
        if (hadoopClusterItem != null) {
            HCRepositoryUtil.removeFromHadoopCluster(hadoopClusterItem, hadoopSubConnectionItem.getProperty().getId());
        }
    }
}
Also used : HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)

Example 5 with HadoopSubConnectionItem

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

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