/** * Since the exported transformation that runs this will reside in a ZIP file, we can't reference * files relatively. So what this does is turn the name of the base path into an absolute path. * * @param space the variable space to use * @param definitions * @param resourceNamingInterface * @param repository The repository to optionally load other resources from (to be converted to * XML) * @param metaStore the metaStore in which non-kettle metadata could reside. * @return the filename of the exported resource */ public String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions, ResourceNamingInterface resourceNamingInterface, Repository repository, IMetaStore metaStore) throws KettleException { try { // The object that we're modifying here is a copy of the original! // So let's change the filename from relative to absolute by grabbing the file object... // In case the name of the file comes from previous steps, forget about this! // if (!fileNameInField) { if (!Const.isEmpty(fileName)) { FileObject fileObject = KettleVFS.getFileObject(space.environmentSubstitute(fileName), space); fileName = resourceNamingInterface.nameResource(fileObject, space, true); } } return null; } catch (Exception e) { throw new KettleException(e); } }
/** * Since the exported transformation that runs this will reside in a ZIP file, we can't reference * files relatively. So what this does is turn the name of files into absolute paths OR it simply * includes the resource in the ZIP file. For now, we'll simply turn it into an absolute path and * pray that the file is on a shared drive or something like that. * * <p>TODO: create options to configure this behavior */ public String exportResources( VariableSpace space, Map<String, ResourceDefinition> definitions, ResourceNamingInterface resourceNamingInterface, Repository repository) throws KettleException { try { // The object that we're modifying here is a copy of the original! // So let's change the filename from relative to absolute by grabbing the file object... // In case the name of the file comes from previous steps, forget about this! // if (Const.isEmpty(filenameField)) { // From : ${Internal.Transformation.Filename.Directory}/../foo/bar.csv // To : /home/matt/test/files/foo/bar.csv // FileObject fileObject = KettleVFS.getFileObject(space.environmentSubstitute(filename)); // If the file doesn't exist, forget about this effort too! // if (fileObject.exists()) { // Convert to an absolute path... // filename = resourceNamingInterface.nameResource( fileObject.getName().getBaseName(), fileObject.getParent().getName().getPath(), space.toString(), FileNamingType.DATA_FILE); return filename; } } return null; } catch (Exception e) { throw new KettleException(e); // $NON-NLS-1$ } }