use of org.pentaho.di.repository.filerep.KettleFileRepository in project pentaho-kettle by pentaho.
the class RepositoryExporter method convertFromFileRepository.
private void convertFromFileRepository(TransMeta transMeta) {
Object[] metaInjectObjectArray = new Object[4];
metaInjectObjectArray[0] = transMeta;
metaInjectObjectArray[1] = PKG;
if (repository instanceof KettleFileRepository) {
KettleFileRepository fileRep = (KettleFileRepository) repository;
metaInjectObjectArray[2] = fileRep;
// The id of the transformation is the relative filename.
// Setting the filename also sets internal variables needed to load the trans/job referenced.
//
String transMetaFilename = fileRep.calcFilename(transMeta.getObjectId());
transMeta.setFilename(transMetaFilename);
for (StepMeta stepMeta : transMeta.getSteps()) {
if (stepMeta.isMapping()) {
MappingMeta mappingMeta = (MappingMeta) stepMeta.getStepMetaInterface();
//
if (mappingMeta.getSpecificationMethod() == ObjectLocationSpecificationMethod.FILENAME) {
try {
TransMeta meta = MappingMeta.loadMappingMeta(mappingMeta, fileRep, fileRep.metaStore, transMeta);
FileObject fileObject = KettleVFS.getFileObject(meta.getFilename());
mappingMeta.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
mappingMeta.setFileName(null);
mappingMeta.setTransName(meta.getName());
mappingMeta.setDirectoryPath(Const.NVL(calcRepositoryDirectory(fileRep, fileObject), "/"));
} catch (Exception e) {
log.logError(BaseMessages.getString(PKG, "Repository.Exporter.Log.UnableToLoadTransInMap", mappingMeta.getName()), e);
}
}
}
metaInjectObjectArray[3] = stepMeta;
try {
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.RepositoryExporterPatchTransStep.id, metaInjectObjectArray);
} catch (KettleException ke) {
log.logError(ke.getMessage(), ke);
}
}
}
}
use of org.pentaho.di.repository.filerep.KettleFileRepository in project pentaho-kettle by pentaho.
the class JobExportIT method setUp.
@Before
public void setUp() throws KettleException {
KettleFileRepositoryMeta repositoryMeta = new KettleFileRepositoryMeta(FILE_REPOSITORY_ID, FILE_REPOSITORY_NAME, FILE_REPOSITORY_DESC, REPOSITORY_ROOT_DIR);
repository = new KettleFileRepository();
repository.init(repositoryMeta);
repository.connect(null, null);
}
use of org.pentaho.di.repository.filerep.KettleFileRepository in project pentaho-kettle by pentaho.
the class JobImportIT method setUp.
@Before
public void setUp() throws KettleException {
KettleEnvironment.init();
Props.init(Props.TYPE_PROPERTIES_SPOON);
deleteFolder(new File(REPOSITORY_ROOT_DIR));
KettleFileRepositoryMeta repositoryMeta = new KettleFileRepositoryMeta(FILE_REPOSITORY_ID, FILE_REPOSITORY_NAME, FILE_REPOSITORY_DESC, REPOSITORY_ROOT_DIR);
repository = new KettleFileRepository();
repository.init(repositoryMeta);
repository.connect(null, null);
importer = new RepositoryImporter(repository);
}
use of org.pentaho.di.repository.filerep.KettleFileRepository in project pentaho-kettle by pentaho.
the class KettleFileRepositoryIT method testDatabaseRepository.
public void testDatabaseRepository() throws Exception {
KettleEnvironment.init();
String dirName = System.getProperty("java.io.tmpdir") + "/" + UUID.randomUUID();
File dirFile = new File(dirName);
if (!dirFile.mkdir()) {
throw new KettleException("bad luck, directory '" + dirName + "' already exists and can't be used to put a file repository in it.");
}
System.out.println("Using folder '" + dirName + "' to store a file repository in.");
try {
repositoryMeta = new KettleFileRepositoryMeta("KettleFileRepository", "FileRep", "File repository", dirName);
repository = new KettleFileRepository();
repository.init(repositoryMeta);
// Test connecting... (no security needed)
//
repository.connect(null, null);
assertTrue(repository.isConnected());
// Test loading the directory tree
//
tree = repository.loadRepositoryDirectoryTree();
assertNotNull(tree);
// Test directory creation
//
RepositoryDirectoryInterface fooDirectory = repository.createRepositoryDirectory(tree, "foo");
RepositoryDirectoryInterface barDirectory = repository.createRepositoryDirectory(fooDirectory, "bar");
RepositoryDirectoryInterface samplesDirectory = repository.createRepositoryDirectory(fooDirectory, "samples");
// Test directory path lookup
RepositoryDirectoryInterface checkBar = tree.findDirectory("/foo/bar");
assertNotNull(checkBar);
assertTrue(checkBar.equals(barDirectory));
// Save all the transformations samples.
//
verifyTransformationSamples(samplesDirectory);
verifyJobSamples(samplesDirectory);
// Verify metastore functionality
//
IMetaStore metaStore = repository.getMetaStore();
KettleMetaStoreTestBase testBase = new KettleMetaStoreTestBase();
testBase.testFunctionality(metaStore);
// Test directory deletion
repository.deleteRepositoryDirectory(samplesDirectory);
RepositoryDirectoryInterface checkDelete = tree.findDirectory("/foo/bar/samples");
assertNull(checkDelete);
// Finally test disconnecting
repository.disconnect();
assertFalse(repository.isConnected());
} catch (Exception e) {
e.printStackTrace();
throw new KettleException("Error during database repository unit testing", e);
} finally {
// Remove all the files and folders in the repository...
//
FileUtils.deleteDirectory(dirFile);
}
}
use of org.pentaho.di.repository.filerep.KettleFileRepository in project pentaho-metaverse by pentaho.
the class DIRepositoryLocatorTest method testGetContentsKettleFileRepository.
@Test
public void testGetContentsKettleFileRepository() throws Exception {
when(spyLocator.getRepository()).thenReturn(new KettleFileRepository());
spyLocator.getContents(repositoryFile);
}
Aggregations