private RepositoryDirectoryInterface getRepositoryRoot() throws KettleException { if ( root == null ) { root = rep.loadRepositoryDirectoryTree(); } return root; }
@Override public RepositoryDirectoryInterface loadRepositoryDirectoryTree() throws KettleException { return getDelegate().loadRepositoryDirectoryTree(); }
private JobMeta getJobMetaFromRepository( Repository rep, CurrentDirectoryResolver r, String transPath ) throws KettleException { String realJobName = ""; String realDirectory = "/"; int index = transPath.lastIndexOf( RepositoryFile.SEPARATOR ); if ( index != -1 ) { realJobName = transPath.substring( index + 1 ); realDirectory = index == 0 ? RepositoryFile.SEPARATOR : transPath.substring( 0, index ); } realDirectory = r.normalizeSlashes( realDirectory ); RepositoryDirectoryInterface repositoryDirectory = rep.loadRepositoryDirectoryTree().findDirectory( realDirectory ); if ( repositoryDirectory == null ) { throw new KettleException( "Unable to find repository directory [" + Const.NVL( realDirectory, "" ) + "]" ); } return rep.loadJob( realJobName, repositoryDirectory, null, null ); // reads }
private JobMeta loadJob( Repository repository, String job ) throws KettleException { if ( repository == null ) { throw new KettleException( "Repository required." ); } else { synchronized ( repository ) { // With a repository we need to load it from /foo/bar/Transformation // We need to extract the folder name from the path in front of the // name... // String directoryPath; String name; int lastSlash = job.lastIndexOf( RepositoryDirectory.DIRECTORY_SEPARATOR ); if ( lastSlash < 0 ) { directoryPath = "/"; name = job; } else { directoryPath = job.substring( 0, lastSlash ); name = job.substring( lastSlash + 1 ); } RepositoryDirectoryInterface directory = repository.loadRepositoryDirectoryTree().findDirectory( directoryPath ); ObjectId jobID = repository.getJobId( name, directory ); JobMeta transJob = repository.loadJob( jobID, null ); return transJob; } } }
private TransMeta loadTrans( Repository repository, String transformationName ) throws KettleException { if ( repository == null ) { throw new KettleException( "Repository required." ); } else { synchronized ( repository ) { // With a repository we need to load it from /foo/bar/Transformation // We need to extract the folder name from the path in front of the // name... // String directoryPath; String name; int lastSlash = transformationName.lastIndexOf( RepositoryDirectory.DIRECTORY_SEPARATOR ); if ( lastSlash < 0 ) { directoryPath = "/"; name = transformationName; } else { directoryPath = transformationName.substring( 0, lastSlash ); name = transformationName.substring( lastSlash + 1 ); } RepositoryDirectoryInterface directory = repository.loadRepositoryDirectoryTree().findDirectory( directoryPath ); ObjectId transformationId = repository.getTransformationID( name, directory ); TransMeta transMeta = repository.loadTransformation( transformationId, null ); return transMeta; } } }
private TransMeta getTransMetaFromRepository( Repository rep, CurrentDirectoryResolver r, String transPath ) throws KettleException { String realTransName = ""; String realDirectory = "/"; if ( StringUtils.isBlank( transPath ) ) { throw new KettleException( BaseMessages.getString( PKG, "JobTrans.Exception.MissingTransFileName" ) ); } int index = transPath.lastIndexOf( RepositoryFile.SEPARATOR ); if ( index != -1 ) { realTransName = transPath.substring( index + 1 ); realDirectory = index == 0 ? RepositoryFile.SEPARATOR : transPath.substring( 0, index ); } realDirectory = r.normalizeSlashes( realDirectory ); RepositoryDirectoryInterface repositoryDirectory = rep.loadRepositoryDirectoryTree().findDirectory( realDirectory ); if ( repositoryDirectory == null ) { throw new KettleException( "Unable to find repository directory [" + Const.NVL( realDirectory, "" ) + "]" ); } return rep.loadTransformation( realTransName, repositoryDirectory, null, true, null ); }
repository.loadRepositoryDirectoryTree().findDirectory( directoryPath ); if ( directory == null ) { throw new KettleException( "Unable to find directory path '" + directoryPath + "' in the repository" );
repository.loadRepositoryDirectoryTree().findDirectory( directoryPath ); if ( directory == null ) { throw new KettleException( "Unable to find directory path '" + directoryPath + "' in the repository" );
/** * When connected to the repository and {@link JobEntryJob} references a child job by name using a single parameter, * keep {@link ObjectLocationSpecificationMethod} as {@code REPOSITORY_BY_NAME}. * Load the job from the repository using the specified job name and directory. */ @Test public void testConnectedLoad_RepByName_SingleParameter() throws Exception { Repository myrepo = mock( Repository.class ); doReturn( true ).when( myrepo ).isConnected(); doReturn( rdi ).when( myrepo ).loadRepositoryDirectoryTree(); doReturn( null ).when( myrepo ).getJobEntryAttributeString( any( ObjectId.class ), anyString() ); doReturn( "rep_name" ).when( myrepo ).getJobEntryAttributeString( JOB_ENTRY_JOB_OBJECT_ID, "specification_method" ); doReturn( "${repositoryfullfilepath}" ).when( myrepo ).getJobEntryAttributeString( JOB_ENTRY_JOB_OBJECT_ID, "name" ); JobEntryJob jej = spy( new JobEntryJob( JOB_ENTRY_JOB_NAME ) ); jej.loadRep( myrepo, store, JOB_ENTRY_JOB_OBJECT_ID, databases, servers ); jej.getJobMeta( myrepo, store, space ); assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, jej.getSpecificationMethod() ); verify( myrepo, times( 1 ) ).loadJob( "job.kjb", directory, null, null ); }
@Before public void setUp() throws Exception { doReturn( true ).when( repository ).isConnected(); doReturn( null ).when( repository ).getJobEntryAttributeString( any( ObjectId.class ), anyString() ); doReturn( rdi ).when( repository ).loadRepositoryDirectoryTree(); doReturn( directory ).when( rdi ).findDirectory( JOB_ENTRY_FILE_DIRECTORY ); doReturn( directory ).when( rdi ).findDirectory( "/home/admin/folder" ); doReturn( null ).when( space ).environmentSubstitute( anyString() ); doReturn( "" ).when( space ).environmentSubstitute( "" ); doReturn( JOB_ENTRY_FILE_PATH ).when( space ).environmentSubstitute( JOB_ENTRY_FILE_PATH ); doReturn( JOB_ENTRY_FILE_NAME ).when( space ).environmentSubstitute( JOB_ENTRY_FILE_NAME ); doReturn( JOB_ENTRY_FILE_DIRECTORY ).when( space ).environmentSubstitute( JOB_ENTRY_FILE_DIRECTORY ); doReturn( "hdfs://server/path/" ).when( space ).environmentSubstitute( "${hdfs}" ); doReturn( "/home/admin/folder/job.kjb" ).when( space ).environmentSubstitute( "${repositoryfullfilepath}" ); doReturn( "/home/admin/folder/" ).when( space ).environmentSubstitute( "${repositorypath}" ); doReturn( "job.kjb" ).when( space ).environmentSubstitute( "${jobname}" ); doReturn( "job" ).when( space ).environmentSubstitute( "job" ); doCallRealMethod().when( resolver ).normalizeSlashes( anyString() ); doReturn( space ).when( resolver ).resolveCurrentDirectory( any( ObjectLocationSpecificationMethod.class ), any( VariableSpace.class ), any( Repository.class ), any( Job.class ), anyString() ); whenNew( CurrentDirectoryResolver.class ).withNoArguments().thenReturn( resolver ); whenNew( JobMeta.class ).withAnyArguments().thenReturn( mock( JobMeta.class ) ); }
/** * When connected to the repository and {@link JobEntryJob} references a child job by name, * guess {@link ObjectLocationSpecificationMethod} as {@code REPOSITORY_BY_NAME}. * Load the job from the repository using the specified job name and directory. */ @Test public void testConnectedLoad_RepByName_Guess() throws Exception { Repository myrepo = mock( Repository.class ); doReturn( true ).when( myrepo ).isConnected(); doReturn( rdi ).when( myrepo ).loadRepositoryDirectoryTree(); doReturn( null ).when( myrepo ).getJobEntryAttributeString( any( ObjectId.class ), anyString() ); doReturn( JOB_ENTRY_FILE_NAME ).when( myrepo ).getJobEntryAttributeString( JOB_ENTRY_JOB_OBJECT_ID, "name" ); doReturn( JOB_ENTRY_FILE_DIRECTORY ).when( myrepo ).getJobEntryAttributeString( JOB_ENTRY_JOB_OBJECT_ID, "dir_path" ); JobEntryJob jej = spy( new JobEntryJob( JOB_ENTRY_JOB_NAME ) ); jej.loadRep( myrepo, store, JOB_ENTRY_JOB_OBJECT_ID, databases, servers ); jej.getJobMeta( myrepo, store, space ); assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, jej.getSpecificationMethod() ); verify( myrepo, times( 1 ) ).loadJob( JOB_ENTRY_FILE_NAME, directory, null, null ); }
/** * When connected to the repository and {@link JobEntryJob} references a child job by name, * keep {@link ObjectLocationSpecificationMethod} as {@code REPOSITORY_BY_NAME}. * Load the job from the repository using the specified job name and directory. */ @Test public void testConnectedLoad_RepByName() throws Exception { Repository myrepo = mock( Repository.class ); doReturn( true ).when( myrepo ).isConnected(); doReturn( rdi ).when( myrepo ).loadRepositoryDirectoryTree(); doReturn( null ).when( myrepo ).getJobEntryAttributeString( any( ObjectId.class ), anyString() ); doReturn( "rep_name" ).when( myrepo ).getJobEntryAttributeString( JOB_ENTRY_JOB_OBJECT_ID, "specification_method" ); doReturn( JOB_ENTRY_FILE_NAME ).when( myrepo ).getJobEntryAttributeString( JOB_ENTRY_JOB_OBJECT_ID, "name" ); doReturn( JOB_ENTRY_FILE_DIRECTORY ).when( myrepo ).getJobEntryAttributeString( JOB_ENTRY_JOB_OBJECT_ID, "dir_path" ); JobEntryJob jej = spy( new JobEntryJob( JOB_ENTRY_JOB_NAME ) ); jej.loadRep( myrepo, store, JOB_ENTRY_JOB_OBJECT_ID, databases, servers ); jej.getJobMeta( myrepo, store, space ); assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, jej.getSpecificationMethod() ); verify( myrepo, times( 1 ) ).loadJob( JOB_ENTRY_FILE_NAME, directory, null, null ); }
/** * When connected to the repository and {@link JobEntryJob} references a child job by name using multiple parameters, * keep {@link ObjectLocationSpecificationMethod} as {@code REPOSITORY_BY_NAME}. * Load the job from the repository using the specified job name and directory. */ @Test public void testConnectedLoad_RepByName_MultipleParameters() throws Exception { Repository myrepo = mock( Repository.class ); doReturn( true ).when( myrepo ).isConnected(); doReturn( rdi ).when( myrepo ).loadRepositoryDirectoryTree(); doReturn( null ).when( myrepo ).getJobEntryAttributeString( any( ObjectId.class ), anyString() ); doReturn( "rep_name" ).when( myrepo ).getJobEntryAttributeString( JOB_ENTRY_JOB_OBJECT_ID, "specification_method" ); doReturn( "${jobname}" ).when( myrepo ).getJobEntryAttributeString( JOB_ENTRY_JOB_OBJECT_ID, "name" ); doReturn( "${repositorypath}" ).when( myrepo ).getJobEntryAttributeString( JOB_ENTRY_JOB_OBJECT_ID, "dir_path" ); JobEntryJob jej = spy( new JobEntryJob( JOB_ENTRY_JOB_NAME ) ); jej.loadRep( myrepo, store, JOB_ENTRY_JOB_OBJECT_ID, databases, servers ); jej.getJobMeta( myrepo, store, space ); assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, jej.getSpecificationMethod() ); verify( myrepo, times( 1 ) ).loadJob( "job.kjb", directory, null, null ); }
@SuppressWarnings( "deprecation" ) public void init( Repository repository ) throws ControllerInitializationException { try { this.repository = repository; mainController = (MainController) this.getXulDomContainer().getEventHandler( "mainController" ); RepositoryDirectoryInterface root; try { if ( repository instanceof RepositoryExtended ) { root = ( (RepositoryExtended) repository ).loadRepositoryDirectoryTree( false ); } else { root = repository.loadRepositoryDirectoryTree(); } this.repositoryDirectory = UIObjectRegistry.getInstance().constructUIRepositoryDirectory( root, null, repository ); } catch ( UIObjectCreationException uoe ) { this.repositoryDirectory = new UIRepositoryDirectory( repository.loadRepositoryDirectoryTree(), null, repository ); } this.repositoryDirectory.populateChildren(); dirMap = new HashMap<ObjectId, UIRepositoryDirectory>(); populateDirMap( repositoryDirectory ); bf = new SwtBindingFactory(); bf.setDocument( this.getXulDomContainer().getDocumentRoot() ); messageBox = (XulMessageBox) document.createElement( "messagebox" ); createBindings(); } catch ( Exception e ) { throw new ControllerInitializationException( e ); } }
when( mockRepository.loadRepositoryDirectoryTree() ).thenReturn( mockRepositoryDirectory );
when( mockRepository.loadRepositoryDirectoryTree() ).thenReturn( mockRepositoryDirectory );
when( mockRepository.loadRepositoryDirectoryTree() ).thenReturn( mockRepositoryDirectory );
when( mockRepository.loadRepositoryDirectoryTree() ).thenReturn( mockRepositoryDirectory );
public RepositoryTree loadDirectoryTree() { if ( getRepository() != null ) { try { if ( getRepository() instanceof RepositoryExtended ) { rootDirectory = ( (RepositoryExtended) getRepository() ).loadRepositoryDirectoryTree( false ); } else { rootDirectory = getRepository().loadRepositoryDirectoryTree(); } RepositoryTree repositoryTree = new RepositoryTree(); RepositoryDirectory repositoryDirectory = RepositoryDirectory.build( null, rootDirectory ); populateFolders( repositoryDirectory, rootDirectory ); boolean isPentahoRepository = getRepository().getRepositoryMeta().getId().equals( PENTAHO_ENTERPRISE_REPOSITORY ); repositoryTree.setIncludeRoot( !isPentahoRepository ); repositoryTree.addChild( repositoryDirectory ); return repositoryTree; } catch ( Exception e ) { return null; } } return null; }
RepositoryDirectoryInterface directory = repository.loadRepositoryDirectoryTree(); // Default = root