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);
}
}
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);
}
}
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;
}
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;
}
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);
}
}
Aggregations