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