Search in sources :

Example 1 with UICluster

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();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) UICluster(org.pentaho.di.ui.repository.repositoryexplorer.model.UICluster) ObjectId(org.pentaho.di.repository.ObjectId) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ClusterSchema(org.pentaho.di.cluster.ClusterSchema) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 2 with UICluster

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);
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) UICluster(org.pentaho.di.ui.repository.repositoryexplorer.model.UICluster) ObjectId(org.pentaho.di.repository.ObjectId) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ClusterSchema(org.pentaho.di.cluster.ClusterSchema) MessageBox(org.eclipse.swt.widgets.MessageBox) ClusterSchemaDialog(org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog)

Example 3 with UICluster

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);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) UICluster(org.pentaho.di.ui.repository.repositoryexplorer.model.UICluster) ObjectId(org.pentaho.di.repository.ObjectId) ArrayList(java.util.ArrayList) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Aggregations

ClusterSchema (org.pentaho.di.cluster.ClusterSchema)3 KettleException (org.pentaho.di.core.exception.KettleException)3 ObjectId (org.pentaho.di.repository.ObjectId)3 UICluster (org.pentaho.di.ui.repository.repositoryexplorer.model.UICluster)3 MessageBox (org.eclipse.swt.widgets.MessageBox)2 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)2 ArrayList (java.util.ArrayList)1 ClusterSchemaDialog (org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog)1