use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class HCRepositoryUtil method getHadoopClusterItemBySubitemId.
public static HadoopClusterConnectionItem getHadoopClusterItemBySubitemId(String subitemId) {
ProjectManager projectManager = ProjectManager.getInstance();
HadoopClusterConnectionItem item = getHadoopClusterItemBySubitemId(projectManager.getCurrentProject(), subitemId);
if (item == null) {
// if not exist in current project, try to find it from reference projects
List<Project> allReferencedProjects = projectManager.getAllReferencedProjects();
for (Project referencedProject : allReferencedProjects) {
item = getHadoopClusterItemBySubitemId(referencedProject, subitemId);
if (item != null) {
break;
}
}
}
return item;
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class HCRepositoryUtil method getSubitemsOfHadoopCluster.
/**
* DOC ycbai Comment method "getSubitemsOfHadoopCluster".
*
* Get subitems of hadoop cluster like hdfs, hcatalog, hive etc.
*
* @param item
* @return
* @throws PersistenceException
*/
public static Set<Item> getSubitemsOfHadoopCluster(Item item) throws PersistenceException {
Set<Item> subItems = new HashSet<Item>();
if (item.eClass() != HadoopClusterPackage.Literals.HADOOP_CLUSTER_CONNECTION_ITEM) {
return subItems;
}
Project project = new Project(ProjectManager.getInstance().getProject(item.getProperty()));
HadoopClusterConnectionItem clusterConnectionItem = (HadoopClusterConnectionItem) item;
HadoopClusterConnection clusterConnection = (HadoopClusterConnection) clusterConnectionItem.getConnection();
EList<String> connectionList = clusterConnection.getConnectionList();
for (String connId : connectionList) {
if (connId != null) {
IRepositoryViewObject repObj = ProxyRepositoryFactory.getInstance().getLastVersion(project, connId);
if (repObj != null && repObj.getProperty() != null) {
Item subItem = repObj.getProperty().getItem();
if (subItem != null) {
subItems.add(subItem);
}
}
}
}
String clusterId = clusterConnectionItem.getProperty().getId();
List<IRepositoryViewObject> repObjs = ProxyRepositoryFactory.getInstance().getAll(project, ERepositoryObjectType.METADATA_CONNECTIONS);
for (IRepositoryViewObject repObj : repObjs) {
if (repObj != null && repObj.getProperty() != null) {
DatabaseConnectionItem dbItem = (DatabaseConnectionItem) repObj.getProperty().getItem();
DatabaseConnection dbConnection = (DatabaseConnection) dbItem.getConnection();
String hcId = dbConnection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID);
if (clusterId.equals(hcId)) {
subItems.add(dbItem);
}
}
}
return subItems;
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem 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.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class CreateMaprdbAction method hideAction.
@Override
protected boolean hideAction(RepositoryNode node) {
HadoopClusterConnectionItem hcConnectionItem = HCRepositoryUtil.getHCConnectionItemFromRepositoryNode(node);
if (hcConnectionItem != null) {
HadoopClusterConnection hcConnection = (HadoopClusterConnection) hcConnectionItem.getConnection();
DistributionBean maprdbDistribution = HadoopDistributionsHelper.MAPRDB.getDistribution(hcConnection.getDistribution(), false);
if (maprdbDistribution != null) {
IHDistributionVersion hdVersion = maprdbDistribution.getHDVersion(hcConnection.getDfVersion(), false);
if (hdVersion != null) {
// found, don't hide
if (GlobalServiceRegister.getDefault().isServiceRegistered(IHadoopDistributionService.class)) {
IHadoopDistributionService hadoopService = (IHadoopDistributionService) GlobalServiceRegister.getDefault().getService(IHadoopDistributionService.class);
if (hadoopService != null) {
return !hadoopService.doSupportMapRTicket(hdVersion);
}
}
}
}
}
return true;
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class CreateHiveAction method hideAction.
@Override
protected boolean hideAction(RepositoryNode node) {
HadoopClusterConnectionItem hcConnectionItem = HCRepositoryUtil.getHCConnectionItemFromRepositoryNode(node);
if (hcConnectionItem != null) {
HadoopClusterConnection hcConnection = (HadoopClusterConnection) hcConnectionItem.getConnection();
DistributionBean hiveDistribution = HadoopDistributionsHelper.HIVE.getDistribution(hcConnection.getDistribution(), false);
if (hiveDistribution != null) {
IHDistributionVersion hdVersion = hiveDistribution.getHDVersion(hcConnection.getDfVersion(), false);
if (hdVersion != null && !IMicrosoftHDInsightDistribution.DISTRIBUTION_NAME.equals(hdVersion.getDistribution().getName())) {
// found and not HD Insight, don't hide
return false;
}
}
}
return true;
}
Aggregations