Search in sources :

Example 21 with ObjectId

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

the class KettleDatabaseRepositoryDatabaseDelegate method deleteDatabaseMeta.

/**
 * Remove a database connection from the repository
 *
 * @param databaseName
 *          The name of the connection to remove
 * @throws KettleException
 *           In case something went wrong: database error, insufficient permissions, depending objects, etc.
 */
public void deleteDatabaseMeta(String databaseName) throws KettleException {
    repository.getSecurityProvider().validateAction(RepositoryOperation.DELETE_DATABASE);
    try {
        ObjectId id_database = getDatabaseID(databaseName);
        delDatabase(id_database);
    } catch (KettleException dbe) {
        throw new KettleException(BaseMessages.getString(PKG, "KettleDatabaseRepository.Exception.ErrorDeletingConnection.Message", databaseName), dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId)

Example 22 with ObjectId

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

the class KettleDatabaseRepositoryDirectoryDelegate method saveRepositoryDirectory.

public void saveRepositoryDirectory(RepositoryDirectoryInterface dir) throws KettleException {
    try {
        ObjectId id_directory_parent = null;
        if (dir.getParent() != null) {
            id_directory_parent = dir.getParent().getObjectId();
        }
        dir.setObjectId(insertDirectory(id_directory_parent, dir));
        log.logDetailed("New id of directory = " + dir.getObjectId());
        repository.commit();
    } catch (Exception e) {
        throw new KettleException("Unable to save directory [" + dir + "] in the repository", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) KettleException(org.pentaho.di.core.exception.KettleException)

Example 23 with ObjectId

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

the class KettleDatabaseRepositoryDirectoryDelegate method insertDirectory.

/*
   * public synchronized RepositoryDirectory refreshRepositoryDirectoryTree() throws KettleException { try {
   * RepositoryDirectory tree = new RepositoryDirectory(); loadRepositoryDirectory(tree, tree.getID());
   * repository.setDirectoryTree(tree); return tree; } catch (KettleException e) { repository.setDirectoryTree( new
   * RepositoryDirectory() ); throw new KettleException("Unable to read the directory tree from the repository!", e); }
   * }
   */
private synchronized ObjectId insertDirectory(ObjectId id_directory_parent, RepositoryDirectoryInterface dir) throws KettleException {
    ObjectId id = repository.connectionDelegate.getNextDirectoryID();
    String tablename = KettleDatabaseRepository.TABLE_R_DIRECTORY;
    RowMetaAndData table = new RowMetaAndData();
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY), id);
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT), id_directory_parent);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DIRECTORY_DIRECTORY_NAME), dir.getName());
    repository.connectionDelegate.getDatabase().prepareInsert(table.getRowMeta(), tablename);
    repository.connectionDelegate.getDatabase().setValuesInsert(table);
    repository.connectionDelegate.getDatabase().insertRow();
    repository.connectionDelegate.getDatabase().closeInsert();
    return id;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 24 with ObjectId

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

the class KettleDatabaseRepositoryDirectoryDelegate method loadPathToRoot.

public RepositoryDirectoryInterface loadPathToRoot(ObjectId id_directory) throws KettleException {
    List<RepositoryDirectory> path = new ArrayList<>();
    ObjectId directoryId = id_directory;
    RowMetaAndData directoryRow = getDirectory(directoryId);
    Long parentId = directoryRow.getInteger(1);
    // 
    while (parentId != null && parentId >= 0) {
        RepositoryDirectory directory = new RepositoryDirectory();
        // Name of the directory
        directory.setName(directoryRow.getString(2, null));
        directory.setObjectId(directoryId);
        path.add(directory);
        // System.out.println( "+ dir '" + directory.getName() + "'" );
        directoryId = new LongObjectId(parentId);
        directoryRow = getDirectory(directoryId);
        parentId = directoryRow.getInteger(KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT);
    }
    RepositoryDirectory root = new RepositoryDirectory();
    root.setObjectId(new LongObjectId(0));
    path.add(root);
    // 
    for (int i = 0; i < path.size() - 1; i++) {
        RepositoryDirectory item = path.get(i);
        RepositoryDirectory parent = path.get(i + 1);
        item.setParent(parent);
        parent.addSubdirectory(item);
    }
    RepositoryDirectory repositoryDirectory = path.get(0);
    return repositoryDirectory;
}
Also used : RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ArrayList(java.util.ArrayList) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 25 with ObjectId

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

the class KettleDatabaseRepositoryDirectoryDelegate method loadRepositoryDirectory.

public void loadRepositoryDirectory(RepositoryDirectory repositoryDirectory, ObjectId id_directory) throws KettleException {
    if (id_directory == null) {
        // This is the root directory, id = OL
        id_directory = new LongObjectId(0L);
    }
    try {
        RowMetaAndData row = getDirectory(id_directory);
        if (row != null) {
            repositoryDirectory.setObjectId(id_directory);
            // Content?
            // 
            repositoryDirectory.setName(row.getString("DIRECTORY_NAME", null));
            // The sub-directories?
            // 
            ObjectId[] subids = repository.getSubDirectoryIDs(repositoryDirectory.getObjectId());
            for (int i = 0; i < subids.length; i++) {
                RepositoryDirectory subdir = new RepositoryDirectory();
                loadRepositoryDirectory(subdir, subids[i]);
                repositoryDirectory.addSubdirectory(subdir);
            }
        }
    } catch (Exception e) {
        throw new KettleException(BaseMessages.getString(PKG, "Repository.LoadRepositoryDirectory.ErrorLoading.Exception"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) LongObjectId(org.pentaho.di.repository.LongObjectId) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

ObjectId (org.pentaho.di.repository.ObjectId)200 KettleException (org.pentaho.di.core.exception.KettleException)91 LongObjectId (org.pentaho.di.repository.LongObjectId)76 StringObjectId (org.pentaho.di.repository.StringObjectId)52 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)49 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)36 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)33 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)32 ArrayList (java.util.ArrayList)28 Test (org.junit.Test)28 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)28 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)25 MessageBox (org.eclipse.swt.widgets.MessageBox)24 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)18 SlaveServer (org.pentaho.di.cluster.SlaveServer)15 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)14 Matchers.anyString (org.mockito.Matchers.anyString)13 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)13 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)13 KettleFileException (org.pentaho.di.core.exception.KettleFileException)12