use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class HadoopClusterImportHandler method afterImportingItems.
@Override
public void afterImportingItems(IProgressMonitor monitor, ResourcesManager resManager, ImportItem importItem) {
super.afterImportingItems(monitor, resManager, importItem);
Item item = importItem.getItem();
if (item instanceof HadoopClusterConnectionItem) {
// Deploy the conf jars if needed.
HadoopConfsUtils.getConfsJarDefaultNames((HadoopClusterConnectionItem) item, true);
}
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class HadoopClusterRepositoryContentHandler method deleteNode.
@Override
protected void deleteNode(Item item) throws Exception {
final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Project project = new Project(ProjectManager.getInstance().getProject(item.getProperty()));
HadoopClusterConnectionItem hadoopClusterItem = (HadoopClusterConnectionItem) item;
HadoopClusterConnection connection = (HadoopClusterConnection) hadoopClusterItem.getConnection();
List<String> connectionList = connection.getConnectionList();
for (String connId : connectionList) {
IRepositoryViewObject repObj = null;
try {
repObj = factory.getLastVersion(project, connId);
} catch (PersistenceException e) {
// do nothing.
}
if (repObj != null) {
factory.deleteObjectPhysical(repObj);
}
}
connection.getConnectionList().clear();
factory.save(hadoopClusterItem);
// Disconnect db connection to hadoop cluster.
String clusterId = hadoopClusterItem.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)) {
dbConnection.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID, null);
factory.save(dbItem);
}
}
}
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class HadoopClusterRepositoryContentHandler method create.
@Override
public Resource create(IProject project, Item item, int classifierID, IPath path) throws PersistenceException {
Resource itemResource = null;
if (item.eClass() == HadoopClusterPackage.Literals.HADOOP_CLUSTER_CONNECTION_ITEM) {
ERepositoryObjectType type = HadoopClusterRepositoryNodeType.HADOOPCLUSTER;
itemResource = create(project, (HadoopClusterConnectionItem) item, path, type);
}
return itemResource;
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class HCRepositoryUtil method setupConnectionToHadoopCluster.
/**
* DOC ycbai Comment method "setupConnectionToHadoopCluster".
*
* Setup the relation from hadoop subnode to hadoop cluster.
*
* @param node
* @param connectionID
* @throws PersistenceException
*/
public static void setupConnectionToHadoopCluster(IRepositoryNode node, String connectionID) throws PersistenceException {
HadoopClusterConnectionItem hcConnectionItem = getHCConnectionItemFromRepositoryNode(node);
setupConnectionToHadoopCluster(hcConnectionItem, connectionID);
}
use of org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem in project tbd-studio-se by Talend.
the class HCRepositoryUtil method getHCConnectionItemFromRepositoryNode.
/**
* DOC ycbai Comment method "getHCConnectionItemFromRepositoryNode".
*
* Get the HadoopClusterConnectionItem from RepositoryNode recursively.
*
* @param node
* @return
*/
public static HadoopClusterConnectionItem getHCConnectionItemFromRepositoryNode(IRepositoryNode node) {
IRepositoryViewObject viewObject = node.getObject();
ERepositoryObjectType repositoryObjectType = viewObject != null ? viewObject.getRepositoryObjectType() : null;
if (viewObject != null && repositoryObjectType != null && (repositoryObjectType.equals(ERepositoryObjectType.METADATA_CONNECTIONS) || repositoryObjectType.equals(HadoopClusterRepositoryNodeType.HADOOPCLUSTER) || isHadoopSubItem(repositoryObjectType, node))) {
final Property property = viewObject.getProperty();
if (property != null) {
Item item = property.getItem();
if (item instanceof HadoopClusterConnectionItem) {
return (HadoopClusterConnectionItem) item;
} else if (item instanceof ConnectionItem) {
return getRelativeHadoopClusterItem(item);
}
}
} else if (isHadoopFolderNode(node)) {
return getHCConnectionItemFromRepositoryNode(node.getParent());
}
return null;
}
Aggregations