use of org.pentaho.di.repository.RepositoryDirectory in project pentaho-kettle by pentaho.
the class KettleDatabaseRepository method getUserHomeDirectory.
public RepositoryDirectory getUserHomeDirectory() throws KettleException {
RepositoryDirectory root = new RepositoryDirectory();
root.setObjectId(new LongObjectId(0L));
directoryDelegate.loadRepositoryDirectory(root, root.getObjectId());
return root;
}
use of org.pentaho.di.repository.RepositoryDirectory in project pentaho-kettle by pentaho.
the class KettleDatabaseRepository method loadRepositoryDirectoryTree.
// Directory stuff
public RepositoryDirectoryInterface loadRepositoryDirectoryTree() throws KettleException {
RepositoryDirectory root = new RepositoryDirectory();
root.setObjectId(new LongObjectId(0L));
return directoryDelegate.loadRepositoryDirectoryTree(root);
}
use of org.pentaho.di.repository.RepositoryDirectory in project pentaho-kettle by pentaho.
the class StepWithMappingMeta method exportResources.
@Override
public String exportResources(VariableSpace space, Map<String, ResourceDefinition> definitions, ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore) throws KettleException {
try {
// Try to load the transformation from repository or file.
// Modify this recursively too...
//
// NOTE: there is no need to clone this step because the caller is
// responsible for this.
//
// First load the mapping transformation...
//
TransMeta mappingTransMeta = loadMappingMeta(this, repository, metaStore, space);
// Also go down into the mapping transformation and export the files
// there. (mapping recursively down)
//
String proposedNewFilename = mappingTransMeta.exportResources(mappingTransMeta, definitions, resourceNamingInterface, repository, metaStore);
// To get a relative path to it, we inject
// ${Internal.Entry.Current.Directory}
//
String newFilename = "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}/" + proposedNewFilename;
// Set the correct filename inside the XML.
//
mappingTransMeta.setFilename(newFilename);
// exports always reside in the root directory, in case we want to turn
// this into a file repository...
//
mappingTransMeta.setRepositoryDirectory(new RepositoryDirectory());
// change it in the job entry
//
fileName = newFilename;
setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
return proposedNewFilename;
} catch (Exception e) {
throw new KettleException(BaseMessages.getString(PKG, "StepWithMappingMeta.Exception.UnableToLoadTrans", fileName));
}
}
use of org.pentaho.di.repository.RepositoryDirectory in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryDirectoryDelegate method loadRepositoryDirectoryTree.
public RepositoryDirectoryInterface loadRepositoryDirectoryTree(RepositoryDirectoryInterface root) throws KettleException {
try {
synchronized (repository) {
root.clear();
ObjectId[] subids = repository.getSubDirectoryIDs(root.getObjectId());
for (int i = 0; i < subids.length; i++) {
RepositoryDirectory subdir = new RepositoryDirectory();
loadRepositoryDirectory(subdir, subids[i]);
root.addSubdirectory(subdir);
}
}
return root;
} catch (Exception e) {
throw new KettleException("An error occured loading the directory tree from the repository", e);
}
}
use of org.pentaho.di.repository.RepositoryDirectory in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryDirectoryDelegate method renameDirectory.
/**
* Move / rename a directory in the repository
*
* @param id_directory
* Id of the directory to be moved/renamed
* @param id_directory_parent
* Id of the new parent directory (null if the parent does not change)
* @param newName
* New name for this directory (null if the name does not change)
* @throws KettleException
*/
public synchronized void renameDirectory(ObjectId id_directory, ObjectId id_directory_parent, String newName) throws KettleException {
if (id_directory.equals(id_directory_parent)) {
// Make sure the directory cannot become its own parent
throw new KettleException("Failed to copy directory into itself");
} else {
// Make sure the directory does not become a descendant of itself
RepositoryDirectory rd = new RepositoryDirectory();
loadRepositoryDirectory(rd, id_directory);
if (rd.findDirectory(id_directory_parent) != null) {
// The parent directory is a child of this directory. Do not proceed
throw new KettleException("Directory cannot become a child to itself");
} else {
// Check for duplication
RepositoryDirectory newParent = new RepositoryDirectory();
loadRepositoryDirectory(newParent, id_directory_parent);
RepositoryDirectory child = newParent.findChild(newName == null ? rd.getName() : newName);
if (child != null) {
throw new KettleException("Destination directory already contains a diectory with requested name");
}
}
}
if (id_directory_parent != null || newName != null) {
RowMetaAndData r = new RowMetaAndData();
String sql = "UPDATE " + quoteTable(KettleDatabaseRepository.TABLE_R_DIRECTORY) + " SET ";
boolean additionalParameter = false;
if (newName != null) {
additionalParameter = true;
sql += quote(KettleDatabaseRepository.FIELD_DIRECTORY_DIRECTORY_NAME) + " = ?";
r.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DIRECTORY_DIRECTORY_NAME), newName);
}
if (id_directory_parent != null) {
// Add a parameter separator if the first parm was added
if (additionalParameter) {
sql += ", ";
}
sql += quote(KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT) + " = ?";
r.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT), id_directory_parent);
}
sql += " WHERE " + quote(KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY) + " = ? ";
r.addValue(new ValueMetaInteger("id_directory"), Long.valueOf(id_directory.toString()));
repository.connectionDelegate.getDatabase().execStatement(sql, r.getRowMeta(), r.getData());
}
}
Aggregations