use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class MappingMeta method lookupRepositoryReferences.
@Override
public void lookupRepositoryReferences(Repository repository) throws KettleException {
// The correct reference is stored in the trans name and directory attributes...
//
RepositoryDirectoryInterface repositoryDirectoryInterface = RepositoryImportLocation.getRepositoryImportLocation().findDirectory(directoryPath);
transObjectId = repository.getTransformationID(transName, repositoryDirectoryInterface);
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class GetRepositoryNames method getRepositoryObjects.
@SuppressWarnings("deprecation")
private List<RepositoryElementMetaInterface> getRepositoryObjects() throws KettleException {
try {
// The repository is available in the parent transformation metadata
//
Repository repository = getTransMeta().getRepository();
// Now populate the list...
//
List<RepositoryElementMetaInterface> list = new ArrayList<RepositoryElementMetaInterface>();
if (repository instanceof RepositoryExtended) {
RepositoryExtended extendedRep = (RepositoryExtended) repository;
for (int i = 0; i < meta.getDirectory().length; i++) {
String directoryPath = environmentSubstitute(meta.getDirectory()[i]);
String filter = null;
// by default we look for current level
int depth = 0;
if (meta.getObjectTypeSelection().areTransformationsSelected()) {
filter = "*.ktr";
}
if (meta.getObjectTypeSelection().areJobsSelected()) {
// if we have selected the job and transformation than we have applied filter with both condition
filter = Utils.isEmpty(filter) ? "*.kjb" : filter + "|*.kjb";
}
// should include unlimited subfolder
if (meta.getIncludeSubFolders()[i]) {
depth = -1;
}
RepositoryDirectoryInterface directory = extendedRep.loadRepositoryDirectoryTree(directoryPath, filter, depth, BooleanUtils.isTrue(repository.getUserInfo().isAdmin()), false, false);
list.addAll(getRepositoryObjects(directory, environmentSubstitute(meta.getNameMask()[i]), environmentSubstitute(meta.getExcludeNameMask()[i])));
}
} else {
// Get the repository directory tree.
//
RepositoryDirectoryInterface tree = repository.loadRepositoryDirectoryTree();
//
for (int i = 0; i < meta.getDirectory().length; i++) {
RepositoryDirectoryInterface dir = tree.findDirectory(environmentSubstitute(meta.getDirectory()[i]));
if (dir != null) {
List<RepositoryElementMetaInterface> objects = getRepositoryObjects(repository, dir, meta.getIncludeSubFolders()[i], environmentSubstitute(meta.getNameMask()[i]), environmentSubstitute(meta.getExcludeNameMask()[i]));
list.addAll(objects);
}
}
}
return list;
} catch (Exception e) {
throw new KettleException("Unable to get the list of repository objects from the repository", e);
}
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class GetRepositoryNames method getRepositoryObjects.
private List<RepositoryElementMetaInterface> getRepositoryObjects(Repository repository, RepositoryDirectoryInterface directory, boolean subdirs, String nameMask, String excludeNameMask) throws KettleException {
List<RepositoryElementMetaInterface> list = new ArrayList<RepositoryElementMetaInterface>();
List<RepositoryElementMetaInterface> objects = new ArrayList<RepositoryElementMetaInterface>();
if (meta.getObjectTypeSelection().areTransformationsSelected()) {
objects.addAll(repository.getTransformationObjects(directory.getObjectId(), false));
}
if (meta.getObjectTypeSelection().areJobsSelected()) {
objects.addAll(repository.getJobObjects(directory.getObjectId(), false));
}
for (RepositoryElementMetaInterface object : objects) {
boolean add = false;
if (Utils.isEmpty(nameMask) || object.getName().matches(nameMask)) {
add = true;
}
if (!Utils.isEmpty(excludeNameMask) && object.getName().matches(excludeNameMask)) {
add = false;
}
if (add) {
list.add(object);
}
}
if (subdirs) {
for (RepositoryDirectoryInterface child : directory.getChildren()) {
list.addAll(getRepositoryObjects(repository, child, subdirs, nameMask, excludeNameMask));
}
}
return list;
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class Slf4jLoggingEventListener method getDetailedSubject.
private String getDetailedSubject(LoggingObjectInterface loggingObject) {
LinkedList<String> subjects = new LinkedList<>();
while (loggingObject != null) {
if (loggingObject.getObjectType() == TRANS || loggingObject.getObjectType() == JOB) {
RepositoryDirectoryInterface rd = loggingObject.getRepositoryDirectory();
String filename = loggingObject.getFilename();
if (rd != null) {
String path = rd.getPath();
if (path.equals(SEPARATOR)) {
if (filename != null && filename.length() > 0) {
subjects.add(filename);
}
} else {
subjects.add(path + SEPARATOR + filename);
}
} else if (filename != null && filename.length() > 0) {
subjects.add(filename);
}
}
loggingObject = loggingObject.getParent();
}
if (subjects.size() > 0) {
return subjects.size() > 1 ? formatDetailedSubject(subjects) : subjects.get(0);
} else {
return "";
}
}
use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.
the class KitchenCommandExecutor method executeRepositoryBasedCommand.
public Job executeRepositoryBasedCommand(Repository repository, RepositoryMeta repositoryMeta, final String dirName, final String jobName, final String listJobs, final String listDirs) throws Exception {
if (repository != null && repositoryMeta != null) {
// Define and connect to the repository...
logDebug("Kitchen.Log.Alocate&ConnectRep");
// Default = root
RepositoryDirectoryInterface directory = repository.loadRepositoryDirectoryTree();
// Add the IMetaStore of the repository to our delegation
if (repository.getMetaStore() != null && getMetaStore() != null) {
getMetaStore().addMetaStore(repository.getMetaStore());
}
// Find the directory name if one is specified...
if (!Utils.isEmpty(dirName)) {
directory = directory.findDirectory(dirName);
}
if (directory != null) {
// Check username, password
logDebug("Kitchen.Log.CheckUserPass");
// Load a job
if (!Utils.isEmpty(jobName)) {
logDebug("Kitchen.Log.LoadingJobInfo");
blockAndThrow(getKettleInit());
// reads last version
JobMeta jobMeta = repository.loadJob(jobName, directory, null, null);
logDebug("Kitchen.Log.AllocateJob");
return new Job(repository, jobMeta);
} else if (YES.equalsIgnoreCase(listJobs)) {
// List the jobs in the repository
printRepositoryStoredJobs(repository, directory);
} else if (YES.equalsIgnoreCase(listDirs)) {
// List the directories in the repository
printRepositoryDirectories(repository, directory);
}
} else {
System.out.println(BaseMessages.getString(getPkgClazz(), "Kitchen.Error.CanNotFindSuppliedDirectory", dirName + ""));
repositoryMeta = null;
}
} else {
System.out.println(BaseMessages.getString(getPkgClazz(), "Kitchen.Error.NoRepProvided"));
}
return null;
}
Aggregations