Search in sources :

Example 96 with ObjectId

use of org.pentaho.di.repository.ObjectId 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 97 with ObjectId

use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.

the class ConnectionsController method removeConnection.

public void removeConnection() {
    try {
        Collection<UIDatabaseConnection> connections = connectionsTable.getSelectedItems();
        if (connections != null && !connections.isEmpty()) {
            for (Object obj : connections) {
                if (obj != null && obj instanceof UIDatabaseConnection) {
                    UIDatabaseConnection connection = (UIDatabaseConnection) obj;
                    DatabaseMeta databaseMeta = connection.getDatabaseMeta();
                    // Make sure this connection already exists and store its id for updating
                    ObjectId idDatabase = repository.getDatabaseID(databaseMeta.getName());
                    if (idDatabase == null) {
                        MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                        mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Delete.DoesNotExists.Message", databaseMeta.getName()));
                        mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Delete.Title"));
                        mb.open();
                    } else {
                        repository.deleteDatabaseMeta(databaseMeta.getName());
                        reloadLoadedJobsAndTransformations();
                    }
                }
            }
        } else {
            MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
            mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Message"));
            mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Delete.Title"));
            mb.open();
        }
    } catch (KettleException e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Remove.UnexpectedError.Message"), e);
        }
    } finally {
        refreshConnectionList();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 98 with ObjectId

use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.

the class ConnectionsController method editConnection.

public void editConnection() {
    try {
        Collection<UIDatabaseConnection> connections = connectionsTable.getSelectedItems();
        if (connections != null && !connections.isEmpty()) {
            // Grab the first item in the list & send it to the database dialog
            DatabaseMeta databaseMeta = ((UIDatabaseConnection) connections.toArray()[0]).getDatabaseMeta();
            // Make sure this connection already exists and store its id for updating
            ObjectId idDatabase = repository.getDatabaseID(databaseMeta.getName());
            if (idDatabase == null) {
                MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
                mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.DoesNotExists.Message"));
                mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.DoesNotExists.Title"));
                mb.open();
            } else {
                getDatabaseDialog().setDatabaseMeta(databaseMeta);
                String dbName = getDatabaseDialog().open();
                if (dbName != null) {
                    dbName = dbName.trim();
                    databaseMeta.setName(dbName);
                    databaseMeta.setDisplayName(dbName);
                    if (!dbName.isEmpty()) {
                        ObjectId idRenamed = repository.getDatabaseID(dbName);
                        if (idRenamed == null || idRenamed.equals(idDatabase)) {
                            // renaming to non-existing name or updating the current
                            repository.insertLogEntry(BaseMessages.getString(PKG, "ConnectionsController.Message.UpdatingDatabase", databaseMeta.getName()));
                            repository.save(databaseMeta, Const.VERSION_COMMENT_EDIT_VERSION, null);
                            reloadLoadedJobsAndTransformations();
                        } else {
                            // trying to rename to an existing name - show error dialog
                            showAlreadyExistsMessage();
                        }
                    }
                }
            // We should be able to tell the difference between a cancel and an empty database name
            // 
            // else {
            // MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
            // mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.MissingName.Message"));
            // mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.MissingName.Title"));
            // mb.open();
            // }
            }
        } else {
            MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
            mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Message"));
            mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Title"));
            mb.open();
        }
    } catch (KettleException e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Edit.UnexpectedError.Message"), e);
        }
    } finally {
        refreshConnectionList();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) UIDatabaseConnection(org.pentaho.di.ui.repository.repositoryexplorer.model.UIDatabaseConnection) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 99 with ObjectId

use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.

the class UIRepositoryDirectory method equals.

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    UIRepositoryDirectory other = (UIRepositoryDirectory) obj;
    ObjectId id = getObjectId();
    ObjectId otherId = other.getObjectId();
    if (id == null) {
        if (otherId != null) {
            return false;
        }
    } else if (!id.equals(otherId)) {
        return false;
    }
    return true;
}
Also used : ObjectId(org.pentaho.di.repository.ObjectId)

Example 100 with ObjectId

use of org.pentaho.di.repository.ObjectId in project pentaho-kettle by pentaho.

the class UIRepositoryDirectory method hashCode.

// end PDI-3326 hack
// Must implement equals/hashcode to compare object ids since the cache of directories may be refreshed
// and therefore would not be the same instances
@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    ObjectId id = getObjectId();
    result = prime * result + ((id == null) ? 0 : id.hashCode());
    return result;
}
Also used : ObjectId(org.pentaho.di.repository.ObjectId)

Aggregations

ObjectId (org.pentaho.di.repository.ObjectId)233 KettleException (org.pentaho.di.core.exception.KettleException)94 LongObjectId (org.pentaho.di.repository.LongObjectId)76 StringObjectId (org.pentaho.di.repository.StringObjectId)76 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)49 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)38 Test (org.junit.Test)37 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)37 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)34 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)33 ArrayList (java.util.ArrayList)30 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)29 MessageBox (org.eclipse.swt.widgets.MessageBox)26 Repository (org.pentaho.di.repository.Repository)18 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)18 SlaveServer (org.pentaho.di.cluster.SlaveServer)15 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)14 PartitionSchema (org.pentaho.di.partition.PartitionSchema)14 Matchers.anyString (org.mockito.Matchers.anyString)13 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)13