Search in sources :

Example 6 with KettleFileRepository

use of org.pentaho.di.repository.filerep.KettleFileRepository in project pentaho-metaverse by pentaho.

the class DIRepositoryLocatorTest method testGetUnifiedRepositoryWithBadRepoClass.

@Test
public void testGetUnifiedRepositoryWithBadRepoClass() throws Exception {
    spyLocator.setRepository(new KettleFileRepository());
    spyLocator.getUnifiedRepository(mock(IPentahoSession.class));
}
Also used : IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) KettleFileRepository(org.pentaho.di.repository.filerep.KettleFileRepository) Test(org.junit.Test)

Example 7 with KettleFileRepository

use of org.pentaho.di.repository.filerep.KettleFileRepository in project pentaho-metaverse by pentaho.

the class DIRepositoryLocator method getContents.

@Override
protected Object getContents(RepositoryFile file) throws Exception {
    Object object = null;
    ObjectId objectId;
    Repository repo = getRepository();
    if (repo instanceof KettleFileRepository) {
        objectId = new StringObjectId(file.getPath());
    } else {
        objectId = new StringObjectId(file.getId().toString());
    }
    String extension = FilenameUtils.getExtension(file.getName());
    if ("ktr".equals(extension)) {
        object = repo.loadTransformation(objectId, null);
    } else if ("kjb".equals(extension)) {
        object = repo.loadJob(objectId, null);
    }
    return object;
}
Also used : Repository(org.pentaho.di.repository.Repository) KettleFileRepository(org.pentaho.di.repository.filerep.KettleFileRepository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) KettleFileRepository(org.pentaho.di.repository.filerep.KettleFileRepository)

Example 8 with KettleFileRepository

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

the class RepositoryExporterExtension method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
    Object[] metaInjectObjectArray = (Object[]) object;
    TransMeta transMeta = (TransMeta) metaInjectObjectArray[0];
    Class<?> PKG = (Class<?>) metaInjectObjectArray[1];
    KettleFileRepository fileRep = (KettleFileRepository) metaInjectObjectArray[2];
    StepMeta stepMeta = (StepMeta) metaInjectObjectArray[3];
    if (stepMeta.isEtlMetaInject()) {
        MetaInjectMeta metaInjectMeta = (MetaInjectMeta) stepMeta.getStepMetaInterface();
        // 
        if (metaInjectMeta.getSpecificationMethod() == ObjectLocationSpecificationMethod.FILENAME) {
            try {
                TransMeta meta = MetaInjectMeta.loadTransformationMeta(metaInjectMeta, fileRep, fileRep.metaStore, transMeta);
                FileObject fileObject = KettleVFS.getFileObject(meta.getFilename());
                metaInjectMeta.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
                metaInjectMeta.setFileName(null);
                metaInjectMeta.setTransName(meta.getName());
                metaInjectMeta.setDirectoryPath(Const.NVL(calcRepositoryDirectory(fileRep, fileObject), "/"));
            } catch (Exception e) {
                log.logError(BaseMessages.getString(PKG, "Repository.Exporter.Log.UnableToLoadTransInMDI", metaInjectMeta.getName()), e);
            }
        }
    }
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) FileObject(org.apache.commons.vfs2.FileObject) FileObject(org.apache.commons.vfs2.FileObject) StepMeta(org.pentaho.di.trans.step.StepMeta) KettleFileRepository(org.pentaho.di.repository.filerep.KettleFileRepository) KettleException(org.pentaho.di.core.exception.KettleException) FileSystemException(org.apache.commons.vfs2.FileSystemException)

Example 9 with KettleFileRepository

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

the class RepositoryExporter method convertFromFileRepository.

private void convertFromFileRepository(JobMeta jobMeta) {
    if (repository instanceof KettleFileRepository) {
        KettleFileRepository fileRep = (KettleFileRepository) repository;
        // The id of the job is the filename.
        // Setting the filename also sets internal variables needed to load the trans/job referenced.
        // 
        String jobMetaFilename = fileRep.calcFilename(jobMeta.getObjectId());
        jobMeta.setFilename(jobMetaFilename);
        for (JobEntryCopy copy : jobMeta.getJobCopies()) {
            JobEntryInterface entry = copy.getEntry();
            if (entry instanceof JobEntryTrans) {
                // convert to a named based reference.
                // 
                JobEntryTrans trans = (JobEntryTrans) entry;
                if (trans.getSpecificationMethod() == ObjectLocationSpecificationMethod.FILENAME) {
                    try {
                        TransMeta meta = trans.getTransMeta(repository, repository.getMetaStore(), jobMeta);
                        FileObject fileObject = KettleVFS.getFileObject(meta.getFilename());
                        trans.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
                        trans.setFileName(null);
                        trans.setTransname(meta.getName());
                        trans.setDirectory(Const.NVL(calcRepositoryDirectory(fileRep, fileObject), "/"));
                    } catch (Exception e) {
                        log.logError(BaseMessages.getString(PKG, "Repository.Exporter.Log.UnableToLoadJobTrans", trans.getName()), e);
                    }
                }
            }
            if (entry instanceof JobEntryJob) {
                // convert to a named based reference.
                // 
                JobEntryJob jobEntryJob = (JobEntryJob) entry;
                if (jobEntryJob.getSpecificationMethod() == ObjectLocationSpecificationMethod.FILENAME) {
                    try {
                        JobMeta meta = jobEntryJob.getJobMeta(repository, repository.getMetaStore(), jobMeta);
                        FileObject fileObject = KettleVFS.getFileObject(meta.getFilename());
                        jobEntryJob.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
                        jobEntryJob.setFileName(null);
                        jobEntryJob.setJobName(meta.getName());
                        jobEntryJob.setDirectory(Const.NVL(calcRepositoryDirectory(fileRep, fileObject), "/"));
                    } catch (Exception e) {
                        log.logError(BaseMessages.getString(PKG, "Repository.Exporter.Log.UnableToLoadJobJob", jobEntryJob.getName()), e);
                    }
                }
            }
        }
    }
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobMeta(org.pentaho.di.job.JobMeta) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) TransMeta(org.pentaho.di.trans.TransMeta) FileObject(org.apache.commons.vfs2.FileObject) JobEntryJob(org.pentaho.di.job.entries.job.JobEntryJob) KettleFileRepository(org.pentaho.di.repository.filerep.KettleFileRepository) KettleException(org.pentaho.di.core.exception.KettleException) FileSystemException(org.apache.commons.vfs2.FileSystemException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 10 with KettleFileRepository

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

the class GetRepositoryNamesTest method prepareFileRepository.

private static void prepareFileRepository() throws IOException, KettleException {
    baseDirName = Files.createTempDirectory("GetRepositoryNamesIT");
    RepositoryMeta repoMeta = new KettleFileRepositoryMeta(UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), baseDirName.toString());
    repo = new KettleFileRepository();
    repo.init(repoMeta);
    repo.connect(null, null);
    // Populate
    RepositoryDirectoryInterface rootDir = repo.findDirectory("/");
    RepositoryDirectoryInterface subdir1 = new RepositoryDirectory(rootDir, "subdir1");
    repo.saveRepositoryDirectory(subdir1);
    TransMeta transMeta1 = new TransMeta();
    transMeta1.setName("Trans1");
    transMeta1.setRepositoryDirectory(subdir1);
    repo.save(transMeta1, null, null);
    JobMeta jobMeta1 = new JobMeta();
    jobMeta1.setName("Job1");
    jobMeta1.setRepositoryDirectory(subdir1);
    repo.save(jobMeta1, null, null);
    RepositoryDirectoryInterface subdir2 = new RepositoryDirectory(subdir1, "subdir2");
    repo.saveRepositoryDirectory(subdir2);
    TransMeta transMeta2 = new TransMeta();
    transMeta2.setName("Trans2");
    transMeta2.setRepositoryDirectory(subdir2);
    repo.save(transMeta2, null, null);
    JobMeta jobMeta2 = new JobMeta();
    jobMeta2.setName("Job2");
    jobMeta2.setRepositoryDirectory(subdir2);
    repo.save(jobMeta2, null, null);
}
Also used : KettleFileRepositoryMeta(org.pentaho.di.repository.filerep.KettleFileRepositoryMeta) RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) JobMeta(org.pentaho.di.job.JobMeta) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) TransMeta(org.pentaho.di.trans.TransMeta) KettleFileRepositoryMeta(org.pentaho.di.repository.filerep.KettleFileRepositoryMeta) KettleFileRepository(org.pentaho.di.repository.filerep.KettleFileRepository)

Aggregations

KettleFileRepository (org.pentaho.di.repository.filerep.KettleFileRepository)10 KettleException (org.pentaho.di.core.exception.KettleException)4 KettleFileRepositoryMeta (org.pentaho.di.repository.filerep.KettleFileRepositoryMeta)4 TransMeta (org.pentaho.di.trans.TransMeta)4 FileObject (org.apache.commons.vfs2.FileObject)3 FileSystemException (org.apache.commons.vfs2.FileSystemException)3 File (java.io.File)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Before (org.junit.Before)2 Test (org.junit.Test)2 JobMeta (org.pentaho.di.job.JobMeta)2 StepMeta (org.pentaho.di.trans.step.StepMeta)2 JobEntryJob (org.pentaho.di.job.entries.job.JobEntryJob)1 JobEntryTrans (org.pentaho.di.job.entries.trans.JobEntryTrans)1 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)1 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)1 ObjectId (org.pentaho.di.repository.ObjectId)1 Repository (org.pentaho.di.repository.Repository)1 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)1