@Test public void testProcessLinkedJobsWithFilename() { JobEntryJob jobJobExecutor = spy( new JobEntryJob() ); jobJobExecutor.setFileName( "/path/to/Job1.kjb" ); jobJobExecutor.setSpecificationMethod( ObjectLocationSpecificationMethod.FILENAME ); JobEntryCopy jobEntry = mock( JobEntryCopy.class ); when( jobEntry.getEntry() ).thenReturn( jobJobExecutor ); JobMeta parent = mock( JobMeta.class ); when( parent.nrJobEntries() ).thenReturn( 1 ); when( parent.getJobEntry( 0 ) ).thenReturn( jobEntry ); JobMeta result = jobFileListener.processLinkedJobs( parent ); JobEntryCopy meta = result.getJobEntry( 0 ); assertNotNull( meta ); JobEntryJob resultExecMeta = (JobEntryJob) meta.getEntry(); assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod() ); assertEquals( resultExecMeta.getDirectory(), "/path/to" ); assertEquals( resultExecMeta.getJobName(), "Job1" ); }
protected JobMeta processLinkedJobs( JobMeta jobMeta ) { for ( int i = 0; i < jobMeta.nrJobEntries(); i++ ) { JobEntryCopy jec = jobMeta.getJobEntry( i ); if ( jec.getEntry() instanceof JobEntryJob ) { JobEntryJob jej = (JobEntryJob) jec.getEntry(); ObjectLocationSpecificationMethod specMethod = jej.getSpecificationMethod(); if ( specMethod == ObjectLocationSpecificationMethod.FILENAME ) { jej.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); String filename = jej.getFilename(); String jobname = filename.substring( filename.lastIndexOf( "/" ) + 1, filename.lastIndexOf( '.' ) ); String directory = filename.substring( 0, filename.lastIndexOf( "/" ) ); jej.setJobName( jobname ); jej.setDirectory( directory ); jobMeta.setJobEntry( i, jec ); } } } return jobMeta; }
JobFileListener implements FileListener { protected JobMeta processLinkedJobs( JobMeta jobMeta ) { for ( int i = 0; i < jobMeta.nrJobEntries(); i++ ) { JobEntryCopy jec = jobMeta.getJobEntry( i ); if ( jec.getEntry() instanceof JobEntryJob ) { JobEntryJob jej = (JobEntryJob) jec.getEntry(); ObjectLocationSpecificationMethod specMethod = jej.getSpecificationMethod(); if ( specMethod == ObjectLocationSpecificationMethod.FILENAME ) { jej.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); String filename = jej.getFilename(); String jobname = filename.substring( filename.lastIndexOf( "/" ) + 1, filename.lastIndexOf( '.' ) ); String directory = filename.substring( 0, filename.lastIndexOf( "/" ) ); jej.setJobName( jobname ); jej.setDirectory( directory ); jobMeta.setJobEntry( i, jec ); } } } return jobMeta; } }
JobFileListener implements FileListener { protected JobMeta processLinkedJobs( JobMeta jobMeta ) { for ( int i = 0; i < jobMeta.nrJobEntries(); i++ ) { JobEntryCopy jec = jobMeta.getJobEntry( i ); if ( jec.getEntry() instanceof JobEntryJob ) { JobEntryJob jej = (JobEntryJob) jec.getEntry(); ObjectLocationSpecificationMethod specMethod = jej.getSpecificationMethod(); if ( specMethod == ObjectLocationSpecificationMethod.FILENAME ) { jej.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); String filename = jej.getFilename(); String jobname = filename.substring( filename.lastIndexOf( "/" ) + 1, filename.lastIndexOf( '.' ) ); String directory = filename.substring( 0, filename.lastIndexOf( "/" ) ); jej.setJobName( jobname ); jej.setDirectory( directory ); jobMeta.setJobEntry( i, jec ); } } } return jobMeta; }  }
JobFileListener implements FileListener { protected JobMeta processLinkedJobs( JobMeta jobMeta ) { for ( int i = 0; i < jobMeta.nrJobEntries(); i++ ) { JobEntryCopy jec = jobMeta.getJobEntry( i ); if ( jec.getEntry() instanceof JobEntryJob ) { JobEntryJob jej = (JobEntryJob) jec.getEntry(); ObjectLocationSpecificationMethod specMethod = jej.getSpecificationMethod(); if ( specMethod == ObjectLocationSpecificationMethod.FILENAME ) { jej.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); String filename = jej.getFilename(); String jobname = filename.substring( filename.lastIndexOf( "/" ) + 1, filename.lastIndexOf( '.' ) ); String directory = filename.substring( 0, filename.lastIndexOf( "/" ) ); jej.setJobName( jobname ); jej.setDirectory( directory ); jobMeta.setJobEntry( i, jec ); } } } return jobMeta; }  boolean open( Node jobNode, String fname, boolean importfile ); boolean save( EngineMetaInterface meta, String fname, boolean export ); void syncMetaName( EngineMetaInterface meta, String name ); boolean accepts( String fileName ); boolean acceptsXml( String nodeName ); String[] getFileTypeDisplayNames( Locale locale ); String[] getSupportedExtensions(); String getRootNodeName(); }
JobFileListener implements FileListener { protected JobMeta processLinkedJobs( JobMeta jobMeta ) { for ( int i = 0; i < jobMeta.nrJobEntries(); i++ ) { JobEntryCopy jec = jobMeta.getJobEntry( i ); if ( jec.getEntry() instanceof JobEntryJob ) { JobEntryJob jej = (JobEntryJob) jec.getEntry(); ObjectLocationSpecificationMethod specMethod = jej.getSpecificationMethod(); if ( specMethod == ObjectLocationSpecificationMethod.FILENAME ) { jej.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); String filename = jej.getFilename(); String jobname = filename.substring( filename.lastIndexOf( "/" ) + 1, filename.lastIndexOf( '.' ) ); String directory = filename.substring( 0, filename.lastIndexOf( "/" ) ); jej.setJobName( jobname ); jej.setDirectory( directory ); jobMeta.setJobEntry( i, jec ); } } } return jobMeta; }  boolean open( Node jobNode, String fname, boolean importfile ); boolean save( EngineMetaInterface meta, String fname, boolean export ); void syncMetaName( EngineMetaInterface meta, String name ); boolean accepts( String fileName ); boolean acceptsXml( String nodeName ); String[] getFileTypeDisplayNames( Locale locale ); String[] getSupportedExtensions(); String getRootNodeName();  }