public RepositoryElementInterface dataNodeToElement( final DataNode rootNode ) throws KettleException { JobMeta jobMeta = new JobMeta(); dataNodeToElement( rootNode, jobMeta ); return jobMeta; }
@Override public JobMeta createMeta() { return new JobMeta(); }
private NamedParams getMeta( RepositoryFile file ) throws KettleException { NamedParams meta = null; if ( file != null ) { String extension = FilenameUtils.getExtension( file.getName() ); Repository repo = PDIImportUtil.connectToRepository( null ); if ( "ktr".equalsIgnoreCase( extension ) ) { meta = new TransMeta( convertTransformation( file.getId() ), repo, true, null, null ); } else if ( "kjb".equalsIgnoreCase( extension ) ) { meta = new JobMeta( convertJob( file.getId() ), repo, null ); } } return meta; }
public Job( String name, String file, String[] args ) { this(); jobMeta = new JobMeta(); if ( name != null ) { setName( name + " (" + super.getName() + ")" ); } jobMeta.setName( name ); jobMeta.setFilename( file ); this.arguments = args; init(); this.log = new LogChannel( this ); }
public JobConfiguration( Node configNode ) throws KettleException { Node jobNode = XMLHandler.getSubNode( configNode, JobMeta.XML_TAG ); Node trecNode = XMLHandler.getSubNode( configNode, JobExecutionConfiguration.XML_TAG ); jobExecutionConfiguration = new JobExecutionConfiguration( trecNode ); jobMeta = new JobMeta( jobNode, jobExecutionConfiguration.getRepository(), null ); }
@Override public JobMeta fromXml( String xml, final SharedObjects fakeSharedObjects ) throws Exception { JobMeta meta = spy( new JobMeta() ); doAnswer( createInjectingAnswer( meta, fakeSharedObjects ) ).when( meta ).readSharedObjects(); Document doc = XMLHandler.loadXMLFile( new ByteArrayInputStream( xml.getBytes() ), null, false, false ); meta.loadXML( XMLHandler.getSubNode( doc, JobMeta.XML_TAG ), null, null ); return meta; }
private JobMeta loadJob( ReportSubjectLocation location ) throws KettleException { JobMeta jobMeta; if ( !Utils.isEmpty( location.getFilename() ) ) { jobMeta = new JobMeta( location.getFilename(), repository ); } else { jobMeta = repository.loadJob( location.getName(), location.getDirectory(), null, null ); } return jobMeta; }
public Job executeFilesystemBasedCommand( final String initialDir, final String filename ) throws Exception { if ( Utils.isEmpty( filename ) ) { return null; } blockAndThrow( getKettleInit() ); String fileName = filename; // If the filename starts with scheme like zip:, then isAbsolute() will return false even though // the path following the zip is absolute path. Check for isAbsolute only if the fileName does not start with scheme if ( !KettleVFS.startsWithScheme( fileName ) && !FileUtil.isFullyQualified( fileName ) ) { fileName = initialDir + fileName; } JobMeta jobMeta = new JobMeta( fileName, null, null ); return new Job( null, jobMeta ); }
@Before public void setUp() throws Exception { job = new Job( null, new JobMeta() ); entry = new JobEntryFilesExist(); job.getJobMeta().addJobEntry( new JobEntryCopy( entry ) ); entry.setParentJob( job ); JobMeta mockJobMeta = mock( JobMeta.class ); entry.setParentJobMeta( mockJobMeta ); job.setStopped( false ); existingFile1 = TestUtils.createRamFile( getClass().getSimpleName() + "/existingFile1.ext", entry ); existingFile2 = TestUtils.createRamFile( getClass().getSimpleName() + "/existingFile2.ext", entry ); }
@Test public void recordsCleanUpMethodIsCalled_JobEntryLogTable() throws Exception { JobEntryLogTable jobEntryLogTable = JobEntryLogTable.getDefault( mockedVariableSpace, hasDatabasesInterface ); setAllTableParamsDefault( jobEntryLogTable ); JobMeta jobMeta = new JobMeta( ); jobMeta.setJobEntryLogTable( jobEntryLogTable ); when( mockedJob.getJobMeta() ).thenReturn( jobMeta ); doCallRealMethod().when( mockedJob ).writeJobEntryLogInformation(); mockedJob.writeJobEntryLogInformation(); verify( mockedDataBase ).cleanupLogRecords( jobEntryLogTable ); }
@Before public void setUp() throws Exception { job = new Job( null, new JobMeta() ); entry = new JobEntrySetVariables(); job.getJobMeta().addJobEntry( new JobEntryCopy( entry ) ); entry.setParentJob( job ); job.setStopped( false ); }
@Test public void testUpdateCurrentDirWithRepository( ) { JobMeta jobMetaTest = new JobMeta( ); RepositoryDirectoryInterface path = mock( RepositoryDirectoryInterface.class ); when( path.getPath() ).thenReturn( "aPath" ); jobMetaTest.setRepository( mock( Repository.class ) ); jobMetaTest.setRepositoryDirectory( path ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, "Original value defined at run execution" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, "file:///C:/SomeFilenameDirectory" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY, "/SomeRepDirectory" ); jobMetaTest.updateCurrentDir(); assertEquals( "/SomeRepDirectory", jobMetaTest.getVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY ) ); }
@Test public void testSetInternalEntryCurrentDirectoryWithRepository( ) { JobMeta jobMetaTest = new JobMeta( ); RepositoryDirectoryInterface path = mock( RepositoryDirectoryInterface.class ); when( path.getPath() ).thenReturn( "aPath" ); jobMetaTest.setRepository( mock( Repository.class ) ); jobMetaTest.setRepositoryDirectory( path ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, "Original value defined at run execution" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, "file:///C:/SomeFilenameDirectory" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY, "/SomeRepDirectory" ); jobMetaTest.setInternalEntryCurrentDirectory(); assertEquals( "/SomeRepDirectory", jobMetaTest.getVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY ) ); }
private boolean testEquals( String name, RepositoryDirectoryInterface repDirectory, ObjectRevision revision, String filename ) { JobMeta jobMeta2 = new JobMeta(); jobMeta2.setName( name ); jobMeta2.setRepositoryDirectory( repDirectory ); jobMeta2.setObjectRevision( revision ); jobMeta2.setFilename( filename ); return jobMeta.equals( jobMeta2 ); }
@Before public void setUp() throws Exception { MockDriver.registerInstance(); Job job = new Job( null, new JobMeta() ); entry = new JobEntryEvalTableContent(); job.getJobMeta().addJobEntry( new JobEntryCopy( entry ) ); entry.setParentJob( job ); job.setStopped( false ); DatabaseMeta dbMeta = new DatabaseMeta(); dbMeta.setDatabaseType( "mock-db" ); entry.setDatabase( dbMeta ); }
@Test public void testSetInternalEntryCurrentDirectoryWithoutFilenameOrRepository( ) { JobMeta jobMetaTest = new JobMeta( ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, "Original value defined at run execution" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, "file:///C:/SomeFilenameDirectory" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY, "/SomeRepDirectory" ); jobMetaTest.setInternalEntryCurrentDirectory(); assertEquals( "Original value defined at run execution", jobMetaTest.getVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY ) ); }
@Test public void testUpdateCurrentDirWithoutFilenameOrRepository( ) { JobMeta jobMetaTest = new JobMeta( ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, "Original value defined at run execution" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, "file:///C:/SomeFilenameDirectory" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY, "/SomeRepDirectory" ); jobMetaTest.updateCurrentDir(); assertEquals( "Original value defined at run execution", jobMetaTest.getVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY ) ); }
@Test public void testUpdateCurrentDirWithFilename( ) { JobMeta jobMetaTest = new JobMeta( ); jobMetaTest.setFilename( "hasFilename" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, "Original value defined at run execution" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, "file:///C:/SomeFilenameDirectory" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY, "/SomeRepDirectory" ); jobMetaTest.updateCurrentDir(); assertEquals( "file:///C:/SomeFilenameDirectory", jobMetaTest.getVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY ) ); }
@Test public void testSetInternalEntryCurrentDirectoryWithFilename( ) { JobMeta jobMetaTest = new JobMeta( ); jobMetaTest.setFilename( "hasFilename" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, "Original value defined at run execution" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY, "file:///C:/SomeFilenameDirectory" ); jobMetaTest.setVariable( Const.INTERNAL_VARIABLE_JOB_REPOSITORY_DIRECTORY, "/SomeRepDirectory" ); jobMetaTest.setInternalEntryCurrentDirectory(); assertEquals( "file:///C:/SomeFilenameDirectory", jobMetaTest.getVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY ) ); }
@Test public void testConfigureParameters() throws Exception { JobMeta jobMeta = new JobMeta(); jobMeta.addParameterDefinition( TEST_PARAM_NAME, DEFAULT_PARAM_VALUE, "This tests a default parameter" ); assertEquals( "Default parameter was not set correctly on JobMeta", DEFAULT_PARAM_VALUE, jobMeta.getParameterDefault( TEST_PARAM_NAME ) ); assertEquals( "Parameter value should be blank in JobMeta", "", jobMeta.getParameterValue( TEST_PARAM_NAME ) ); Job job = new Job( null, jobMeta ); job.copyParametersFrom( jobMeta ); assertEquals( "Default parameter was not set correctly on Job", DEFAULT_PARAM_VALUE, job.getParameterDefault( TEST_PARAM_NAME ) ); assertEquals( "Parameter value should be blank in Job", "", job.getParameterValue( TEST_PARAM_NAME ) ); }