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