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