Java Code Examples for org.pentaho.di.core.Const#INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY
The following examples show how to use
org.pentaho.di.core.Const#INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobEntryJob.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * Exports the object to a flat-file system, adding content with filename keys to a set of definitions. The supplied * resource naming interface allows the object to name appropriately without worrying about those parts of the * implementation specific details. * * @param space * The variable space to resolve (environment) variables with. * @param definitions * The map containing the filenames and content * @param namingInterface * The resource naming interface allows the object to be named appropriately * @param repository * The repository to load resources from * @param metaStore * the metaStore to load external metadata from * * @return The filename for this object. (also contained in the definitions map) * @throws KettleException * in case something goes wrong during the export */ @Override public String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions, ResourceNamingInterface namingInterface, Repository repository, IMetaStore metaStore ) throws KettleException { // Try to load the transformation from repository or file. // Modify this recursively too... // // AGAIN: there is no need to clone this job entry because the caller is // responsible for this. // // First load the job meta data... // copyVariablesFrom( space ); // To make sure variables are available. JobMeta jobMeta = getJobMeta( repository, metaStore, space ); // Also go down into the job and export the files there. (going down // recursively) // String proposedNewFilename = jobMeta.exportResources( jobMeta, definitions, namingInterface, repository, metaStore ); // To get a relative path to it, we inject // ${Internal.Entry.Current.Directory} // String newFilename = "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}/" + proposedNewFilename; // Set the filename in the job // jobMeta.setFilename( newFilename ); // exports always reside in the root directory, in case we want to turn this // into a file repository... // jobMeta.setRepositoryDirectory( new RepositoryDirectory() ); // export to filename ALWAYS (this allows the exported XML to be executed remotely) // setSpecificationMethod( ObjectLocationSpecificationMethod.FILENAME ); // change it in the job entry // filename = newFilename; return proposedNewFilename; }
Example 2
Source File: JobEntryTrans.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * We're going to load the transformation meta data referenced here. Then we're going to give it a new filename, * modify that filename in this entries. The parent caller will have made a copy of it, so it should be OK to do so. * <p/> * Exports the object to a flat-file system, adding content with filename keys to a set of definitions. The supplied * resource naming interface allows the object to name appropriately without worrying about those parts of the * implementation specific details. * * @param space The variable space to resolve (environment) variables with. * @param definitions The map containing the filenames and content * @param namingInterface The resource naming interface allows the object to be named appropriately * @param repository The repository to load resources from * @param metaStore the metaStore to load external metadata from * @return The filename for this object. (also contained in the definitions map) * @throws KettleException in case something goes wrong during the export */ @Override public String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions, ResourceNamingInterface namingInterface, Repository repository, IMetaStore metaStore ) throws KettleException { // Try to load the transformation from repository or file. // Modify this recursively too... // // AGAIN: there is no need to clone this job entry because the caller is responsible for this. // // First load the transformation metadata... // copyVariablesFrom( space ); TransMeta transMeta = getTransMeta( repository, space ); // Also go down into the transformation and export the files there. (mapping recursively down) // String proposedNewFilename = transMeta.exportResources( transMeta, definitions, namingInterface, repository, metaStore ); // To get a relative path to it, we inject ${Internal.Entry.Current.Directory} // String newFilename = "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}/" + proposedNewFilename; // Set the correct filename inside the XML. // transMeta.setFilename( newFilename ); // exports always reside in the root directory, in case we want to turn this into a file repository... // transMeta.setRepositoryDirectory( new RepositoryDirectory() ); // export to filename ALWAYS (this allows the exported XML to be executed remotely) // setSpecificationMethod( ObjectLocationSpecificationMethod.FILENAME ); // change it in the job entry // filename = newFilename; return proposedNewFilename; }
Example 3
Source File: JobExecutorMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override public String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions, ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore ) throws KettleException { try { // Try to load the transformation from repository or file. // Modify this recursively too... // // NOTE: there is no need to clone this step because the caller is // responsible for this. // // First load the executor job metadata... // JobMeta executorJobMeta = loadJobMetaProxy( this, repository, space ); // Also go down into the mapping transformation and export the files // there. (mapping recursively down) // String proposedNewFilename = executorJobMeta.exportResources( executorJobMeta, definitions, resourceNamingInterface, repository, metaStore ); // To get a relative path to it, we inject // ${Internal.Entry.Current.Directory} // String newFilename = "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}/" + proposedNewFilename; // Set the correct filename inside the XML. // executorJobMeta.setFilename( newFilename ); // exports always reside in the root directory, in case we want to turn // this into a file repository... // executorJobMeta.setRepositoryDirectory( new RepositoryDirectory() ); // change it in the job entry // fileName = newFilename; setSpecificationMethod( ObjectLocationSpecificationMethod.FILENAME ); return proposedNewFilename; } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "JobExecutorMeta.Exception.UnableToLoadJob", fileName ) ); } }
Example 4
Source File: JobEntryJobDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
String getEntryName( String name ) { return "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}/" + name; }
Example 5
Source File: JobEntryTransDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
String getEntryName( String name ) { return "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}/" + name; }
Example 6
Source File: MetaInjectMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override public String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions, ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore ) throws KettleException { try { // Try to load the transformation from repository or file. // Modify this recursively too... // // NOTE: there is no need to clone this step because the caller is // responsible for this. // // First load the executor transformation metadata... // TransMeta executorTransMeta = loadTransformationMeta( repository, space ); // Also go down into the mapping transformation and export the files // there. (mapping recursively down) // String proposedNewFilename = executorTransMeta.exportResources( executorTransMeta, definitions, resourceNamingInterface, repository, metaStore ); // To get a relative path to it, we inject // ${Internal.Entry.Current.Directory} // String newFilename = "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}/" + proposedNewFilename; // Set the correct filename inside the XML. // executorTransMeta.setFilename( newFilename ); // exports always reside in the root directory, in case we want to turn // this into a file repository... // executorTransMeta.setRepositoryDirectory( new RepositoryDirectory() ); // change it in the entry // fileName = newFilename; setSpecificationMethod( ObjectLocationSpecificationMethod.FILENAME ); return proposedNewFilename; } catch ( Exception e ) { throw new KettleException( BaseMessages.getString( PKG, "MetaInjectMeta.Exception.UnableToLoadTrans", fileName ) ); } }
Example 7
Source File: CsvInputTest.java From pentaho-kettle with Apache License 2.0 | 3 votes |
@Test public void testFilenameValidatorForInputFilesConnectedToRep() { CsvInput csvInput = mock( CsvInput.class ); String internalEntryVariable = "internalEntryVariable"; String internalTransformationVariable = "internalTransformationVariable"; String filename = Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY ; csvInput.setVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, internalEntryVariable ); csvInput.setVariable( Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, internalTransformationVariable ); TransMeta transmeta = mock( TransMeta.class ); Repository rep = mock( Repository.class ); when( csvInput.getTransMeta() ).thenReturn( transmeta ); when( transmeta.getRepository() ).thenReturn( rep ); when( rep.isConnected() ).thenReturn( true ); when( csvInput.filenameValidatorForInputFiles( any() ) ).thenCallRealMethod(); when( csvInput.environmentSubstitute( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY ) ).thenReturn( internalEntryVariable ); when( csvInput.environmentSubstitute( Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY ) ).thenReturn( internalTransformationVariable ); String finalFilename = csvInput.filenameValidatorForInputFiles(filename); assertEquals( internalTransformationVariable, finalFilename ); }
Example 8
Source File: CsvInputTest.java From pentaho-kettle with Apache License 2.0 | 3 votes |
@Test public void testFilenameValidatorForInputFilesNotConnectedToRep() { CsvInput csvInput = mock( CsvInput.class ); String internalEntryVariable = "internalEntryVariable"; String internalTransformationVariable = "internalTransformationVariable"; String filename = Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY ; csvInput.setVariable( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY, internalEntryVariable ); csvInput.setVariable( Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, internalTransformationVariable ); TransMeta transmeta = mock( TransMeta.class ); Repository rep = mock( Repository.class ); when( csvInput.getTransMeta() ).thenReturn( transmeta ); when( transmeta.getRepository() ).thenReturn( rep ); when( rep.isConnected() ).thenReturn( false ); when( csvInput.filenameValidatorForInputFiles( any() ) ).thenCallRealMethod(); when( csvInput.environmentSubstitute( Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY ) ).thenReturn( internalEntryVariable ); when( csvInput.environmentSubstitute( Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY ) ).thenReturn( internalTransformationVariable ); String finalFilename = csvInput.filenameValidatorForInputFiles(filename); assertEquals( internalEntryVariable, finalFilename ); }