Search in sources :

Example 1 with ClusterSchemaDialog

use of org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog in project pentaho-kettle by pentaho.

the class ClustersController method createCluster.

public void createCluster() {
    try {
        ClusterSchema cluster = new ClusterSchema();
        ClusterSchemaDialog clusterDialog = new ClusterSchemaDialog(shell, cluster, repository.getSlaveServers());
        if (clusterDialog.open()) {
            // See if this cluster already exists...
            ObjectId idCluster = repository.getClusterID(cluster.getName());
            if (idCluster == null) {
                if (cluster.getName() != null && !cluster.getName().equals("")) {
                    repository.insertLogEntry(BaseMessages.getString(RepositoryExplorer.class, "ClusterController.Message.CreatingNewCluster", cluster.getName()));
                    repository.save(cluster, Const.VERSION_COMMENT_INITIAL_VERSION, null);
                    if (mainController != null && mainController.getSharedObjectSyncUtil() != null) {
                        mainController.getSharedObjectSyncUtil().reloadTransformationRepositoryObjects(true);
                    }
                } 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.Create.AlreadyExists.Message"));
                mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Create.AlreadyExists.Title"));
                mb.open();
            }
        }
    } catch (KettleException e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Create.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Create.UnexpectedError.Message"), e);
        }
    } finally {
        refreshClusters();
    }
}
Also used : RepositoryExplorer(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorer) KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ClusterSchema(org.pentaho.di.cluster.ClusterSchema) ClusterSchemaDialog(org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 2 with ClusterSchemaDialog

use of org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog in project pentaho-kettle by pentaho.

the class RepositoryExplorerDialog method newCluster.

public void newCluster() {
    try {
        ClusterSchema cluster = new ClusterSchema();
        ClusterSchemaDialog dd = new ClusterSchemaDialog(shell, cluster, rep.getSlaveServers());
        if (dd.open()) {
            // See if this slave server already exists...
            ObjectId idCluster = rep.getClusterID(cluster.getName());
            if (idCluster == null) {
                rep.insertLogEntry("Creating new cluster '" + cluster.getName() + "'");
                rep.save(cluster, Const.VERSION_COMMENT_INITIAL_VERSION, null);
            } else {
                MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Create.AlreadyExists.Message"));
                mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Create.AlreadyExists.Title"));
                mb.open();
            }
            // Refresh tree...
            refreshTree();
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Create.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Cluster.Create.UnexpectedError.Message"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ClusterSchema(org.pentaho.di.cluster.ClusterSchema) ClusterSchemaDialog(org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 3 with ClusterSchemaDialog

use of org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog in project pentaho-kettle by pentaho.

the class SpoonClustersDelegate method editClusterSchema.

public void editClusterSchema(TransMeta transMeta, ClusterSchema clusterSchema) {
    ClusterSchemaDialog dialog = new ClusterSchemaDialog(spoon.getShell(), clusterSchema, transMeta.getClusterSchemas(), transMeta.getSlaveServers());
    if (dialog.open()) {
        if (spoon.rep != null && clusterSchema.getObjectId() != null) {
            try {
                saveSharedObjectToRepository(clusterSchema, null);
            } catch (KettleException e) {
                showSaveError(clusterSchema, e);
            }
        }
        sharedObjectSyncUtil.synchronizeClusterSchemas(clusterSchema);
        spoon.refreshTree();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ClusterSchemaDialog(org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog)

Example 4 with ClusterSchemaDialog

use of org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog in project pentaho-kettle by pentaho.

the class SpoonClustersDelegate method newClusteringSchema.

public void newClusteringSchema(TransMeta transMeta) {
    ClusterSchema clusterSchema = new ClusterSchema();
    ClusterSchemaDialog dialog = new ClusterSchemaDialog(spoon.getShell(), clusterSchema, transMeta.getClusterSchemas(), transMeta.getSlaveServers());
    if (dialog.open()) {
        List<ClusterSchema> clusterSchemas = transMeta.getClusterSchemas();
        if (isDuplicate(clusterSchemas, clusterSchema)) {
            new ErrorDialog(spoon.getShell(), getMessage("Spoon.Dialog.ErrorSavingCluster.Title"), getMessage("Spoon.Dialog.ErrorSavingCluster.Message", clusterSchema.getName()), new KettleException(getMessage("Spoon.Dialog.ErrorSavingCluster.NotUnique")));
            return;
        }
        clusterSchemas.add(clusterSchema);
        if (spoon.rep != null) {
            try {
                if (!spoon.rep.getSecurityProvider().isReadOnly()) {
                    spoon.rep.save(clusterSchema, Const.VERSION_COMMENT_INITIAL_VERSION, null);
                    if (sharedObjectSyncUtil != null) {
                        sharedObjectSyncUtil.reloadTransformationRepositoryObjects(false);
                    }
                } else {
                    throw new KettleException(BaseMessages.getString(PKG, "Spoon.Dialog.Exception.ReadOnlyRepositoryUser"));
                }
            } catch (KettleException e) {
                showSaveError(clusterSchema, e);
            }
        }
        spoon.refreshTree();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ClusterSchema(org.pentaho.di.cluster.ClusterSchema) ClusterSchemaDialog(org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog)

Example 5 with ClusterSchemaDialog

use of org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog 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)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)6 ClusterSchemaDialog (org.pentaho.di.ui.cluster.dialog.ClusterSchemaDialog)6 ClusterSchema (org.pentaho.di.cluster.ClusterSchema)5 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)5 ObjectId (org.pentaho.di.repository.ObjectId)4 MessageBox (org.eclipse.swt.widgets.MessageBox)3 RepositoryExplorer (org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorer)1 UICluster (org.pentaho.di.ui.repository.repositoryexplorer.model.UICluster)1