Search in sources :

Example 91 with RepositoryDirectoryInterface

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);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface)

Example 92 with 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);
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) Repository(org.pentaho.di.repository.Repository) ArrayList(java.util.ArrayList) RepositoryExtended(org.pentaho.di.repository.RepositoryExtended) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Example 93 with RepositoryDirectoryInterface

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;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) ArrayList(java.util.ArrayList) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Example 94 with RepositoryDirectoryInterface

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 "";
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) LinkedList(java.util.LinkedList)

Example 95 with RepositoryDirectoryInterface

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;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) JobMeta(org.pentaho.di.job.JobMeta) Job(org.pentaho.di.job.Job)

Aggregations

RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)163 KettleException (org.pentaho.di.core.exception.KettleException)68 Test (org.junit.Test)32 TransMeta (org.pentaho.di.trans.TransMeta)30 ObjectId (org.pentaho.di.repository.ObjectId)27 JobMeta (org.pentaho.di.job.JobMeta)23 Repository (org.pentaho.di.repository.Repository)22 ArrayList (java.util.ArrayList)17 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)17 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)15 IOException (java.io.IOException)14 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)13 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)11 RepositoryObject (org.pentaho.di.repository.RepositoryObject)11 FileObject (org.apache.commons.vfs2.FileObject)10 List (java.util.List)8 TreeItem (org.eclipse.swt.widgets.TreeItem)8 KettleFileException (org.pentaho.di.core.exception.KettleFileException)8 Date (java.util.Date)7 FileSystemException (org.apache.commons.vfs2.FileSystemException)7