use of org.pentaho.di.ui.repository.repositoryexplorer.model.UICluster in project pentaho-kettle by pentaho.
the class ClustersController method removeCluster.
public void removeCluster() {
String clusterSchemaName = "";
try {
Collection<UICluster> clusters = clustersTable.getSelectedItems();
if (clusters != null && !clusters.isEmpty()) {
for (Object obj : clusters) {
if (obj != null && obj instanceof UICluster) {
UICluster cluster = (UICluster) obj;
ClusterSchema clusterSchema = cluster.getClusterSchema();
clusterSchemaName = clusterSchema.getName();
// Make sure the cluster to delete exists in the repository
ObjectId clusterId = repository.getClusterID(clusterSchema.getName());
if (clusterId == null) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.DoesNotExists.Message", clusterSchema.getName()));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Delete.Title"));
mb.open();
} else {
repository.deleteClusterSchema(clusterId);
if (mainController != null && mainController.getSharedObjectSyncUtil() != null) {
mainController.getSharedObjectSyncUtil().deleteClusterSchema(clusterSchema);
}
}
}
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.NoItemSelected.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Delete.Title"));
mb.open();
}
} catch (KettleException e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Delete.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Delete.UnexpectedError.Message") + clusterSchemaName + "]", e);
}
} finally {
refreshClusters();
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UICluster in project pentaho-kettle by pentaho.
the class ClustersController method editCluster.
public void editCluster() {
String clusterSchemaName = "";
try {
Collection<UICluster> clusters = clustersTable.getSelectedItems();
if (clusters != null && !clusters.isEmpty()) {
// Grab the first item in the list & send it to the cluster schema dialog
ClusterSchema clusterSchema = ((UICluster) clusters.toArray()[0]).getClusterSchema();
clusterSchemaName = clusterSchema.getName();
// Make sure the cluster already exists
ObjectId clusterId = repository.getClusterID(clusterSchema.getName());
if (clusterId == null) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.DoesNotExists.Message", clusterSchemaName));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Edit.Title"));
mb.open();
} else {
ClusterSchemaDialog csd = new ClusterSchemaDialog(shell, clusterSchema, repository.getSlaveServers());
if (csd.open()) {
if (clusterSchema.getName() != null && !clusterSchema.getName().equals("")) {
repository.insertLogEntry(BaseMessages.getString(PKG, "ClusterController.Message.UpdatingCluster", clusterSchema.getName()));
repository.save(clusterSchema, Const.VERSION_COMMENT_EDIT_VERSION, null);
if (mainController != null && mainController.getSharedObjectSyncUtil() != null) {
mainController.getSharedObjectSyncUtil().synchronizeClusterSchemas(clusterSchema, clusterSchemaName);
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Edit.InvalidName.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Edit.Title"));
mb.open();
}
}
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.NoItemSelected.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Edit.Title"));
mb.open();
}
refreshClusters();
} catch (KettleException e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Edit.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Edit.UnexpectedError.Message") + clusterSchemaName + "]", e);
}
}
}
use of org.pentaho.di.ui.repository.repositoryexplorer.model.UICluster in project pentaho-kettle by pentaho.
the class ClustersController method refreshClusters.
public void refreshClusters() {
if (repository != null) {
final List<UICluster> tmpList = new ArrayList<UICluster>();
Runnable r = new Runnable() {
public void run() {
try {
ObjectId[] clusterIdList = repository.getClusterIDs(false);
for (ObjectId clusterId : clusterIdList) {
ClusterSchema cluster = repository.loadClusterSchema(clusterId, repository.getSlaveServers(), null);
// Add the cluster schema to the list
tmpList.add(new UICluster(cluster));
}
} catch (KettleException e) {
// convert to runtime exception so it bubbles up through the UI
throw new RuntimeException(e);
}
}
};
doWithBusyIndicator(r);
clusterList.setChildren(tmpList);
}
}
Aggregations