本文整理汇总了Java中org.pentaho.di.core.vfs.KettleVFS类的典型用法代码示例。如果您正苦于以下问题:Java KettleVFS类的具体用法?Java KettleVFS怎么用?Java KettleVFS使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KettleVFS类属于org.pentaho.di.core.vfs包,在下文中一共展示了KettleVFS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exportResources
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
/**
* 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.
* 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 (!filefield) {
for (int i=0;i<fileName.length;i++) {
FileObject fileObject = KettleVFS.getFileObject(space.environmentSubstitute(fileName[i]), space);
fileName[i] = resourceNamingInterface.nameResource(fileObject, space, Const.isEmpty(fileMask[i]));
}
}
return null;
} catch (Exception e) {
throw new KettleException(e); //$NON-NLS-1$
}
}
示例2: exportResources
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
/**
* 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.
* 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...
//
if (!filefield) {
for (int i=0;i<fileName.length;i++) {
FileObject fileObject = KettleVFS.getFileObject(space.environmentSubstitute(fileName[i]), space);
fileName[i] = resourceNamingInterface.nameResource(fileObject, space, Const.isEmpty(fileMask[i]));
}
}
return null;
} catch (Exception e) {
throw new KettleException(e); //$NON-NLS-1$
}
}
示例3: exportResources
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
/**
* 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.
*/
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 (!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); //$NON-NLS-1$
}
}
示例4: addFileToResultFilenames
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
private void addFileToResultFilenames(String fileaddentry,LogWriter log,Result result,Job parentJob)
{
try
{
ResultFile resultFile = new ResultFile(ResultFile.FILE_TYPE_GENERAL, KettleVFS.getFileObject(fileaddentry), parentJob.getJobname(), toString());
result.getResultFiles().put(resultFile.getFile().toString(), resultFile);
if(log.isDebug())
{
log.logDebug(toString()," ------ ");
log.logDebug(toString(),Messages.getString("JobMoveFiles.Log.FileAddedToResultFilesName",fileaddentry));
}
}catch (Exception e)
{
log.logError(Messages.getString("JobMoveFiles.Error.AddingToFilenameResult"),fileaddentry + ""+e.getMessage());
}
}
示例5: FileExists
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
/**
* Check existence of a local file
*
* @param filename
* @return true, if file exists
*/
public boolean FileExists(String filename) {
FileObject file=null;
try {
file=KettleVFS.getFileObject(filename);
if(!file.exists()) return false;
else
{
if(file.getType() == FileType.FILE) return true;
else return false;
}
} catch (Exception e) {
return false;
}
}
示例6: createFileAppender
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
/**
* Create a file appender
* @param filename The (VFS) filename (URL) to write to.
* @param exact is this an exact filename of a filename to be stored in "java.io.tmp"
* @param append
* @return A new file appender
* @throws KettleFileException In case there is a problem opening the file.
*/
public static final Log4jFileAppender createFileAppender(String filename, boolean exact,boolean append) throws KettleFileException
{
try
{
FileObject file;
if (!exact)
{
file = KettleVFS.createTempFile(filename, ".log", System.getProperty("java.io.tmpdir"));
}
else
{
file = KettleVFS.getFileObject(filename);
}
Log4jFileAppender appender = new Log4jFileAppender(file,append);
appender.setLayout(new Log4jKettleLayout(true));
appender.setName(LogWriter.createFileAppenderName(filename, exact));
return appender;
}
catch(IOException e)
{
throw new KettleFileException("Unable to add Kettle file appender to Log4J", e);
}
}
示例7: getFiles
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
private List<FileObject> getFiles(String localfolder) throws IOException
{
List<FileObject> myFileList = new ArrayList<FileObject>();
// Get all the files in the local directory...
FileObject localFiles = KettleVFS.getFileObject(localfolder);
FileObject[] children = localFiles.getChildren();
if (children!=null)
{
for (int i=0; i<children.length; i++)
{
// Get filename of file or directory
if (children[i].getType().equals(FileType.FILE))
{
myFileList.add(children[i]);
}
} // end for
}
return myFileList;
}
示例8: exportResources
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
/**
* 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.
* 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 (!filefield) {
// Replace the filename ONLY (folder or filename)
//
for (int i=0;i<fileName.length;i++) {
FileObject fileObject = KettleVFS.getFileObject(space.environmentSubstitute(fileName[i]), space);
fileName[i] = resourceNamingInterface.nameResource(fileObject, space, Const.isEmpty(fileMask[i]));
}
}
return null;
} catch (Exception e) {
throw new KettleException(e); //$NON-NLS-1$
}
}
示例9: createRepositoryDirectory
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
public RepositoryDirectoryInterface createRepositoryDirectory(RepositoryDirectoryInterface parentDirectory, String directoryPath) throws KettleException {
String folder = calcDirectoryName(parentDirectory);
String newFolder = folder;
if (folder.endsWith("/")) newFolder+=directoryPath; else newFolder+="/"+directoryPath;
FileObject parent = KettleVFS.getFileObject(newFolder);
try {
parent.createFolder();
} catch (FileSystemException e) {
throw new KettleException("Unable to create folder "+newFolder, e);
}
// Incremental change of the directory structure...
//
RepositoryDirectory newDir = new RepositoryDirectory(parentDirectory, directoryPath);
parentDirectory.addSubdirectory(newDir);
newDir.setObjectId(new StringObjectId(newDir.toString()));
return newDir;
}
示例10: exportResources
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
/**
* 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.
* 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...
//
// From : ${Internal.Transformation.Filename.Directory}/../foo/bar.data
// To : /home/matt/test/files/foo/bar.data
//
FileObject fileObject = KettleVFS.getFileObject(space.environmentSubstitute(filename), space);
// If the file doesn't exist, forget about this effort too!
//
if (fileObject.exists()) {
// Convert to an absolute path...
//
filename = resourceNamingInterface.nameResource(fileObject, space, true);
return filename;
}
return null;
} catch (Exception e) {
throw new KettleException(e); //$NON-NLS-1$
}
}
示例11: exportResources
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
/**
* 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.
* 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...
//
// From : ${Internal.Transformation.Filename.Directory}/../foo/bar.txt
// To : /home/matt/test/files/foo/bar.txt
//
FileObject fileObject = KettleVFS.getFileObject(space.environmentSubstitute(filename), space);
// If the file doesn't exist, forget about this effort too!
//
if (fileObject.exists()) {
// Convert to an absolute path...
//
filename = resourceNamingInterface.nameResource(fileObject, space, true);
return filename;
}
return null;
} catch (Exception e) {
throw new KettleException(e); //$NON-NLS-1$
}
}
示例12: LogChannelFileWriter
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
/**
* Create a new log channel file writer
* @param logChannelId The log channel (+children) to write to the log file
* @param logFile The logging file to write to
* @param appending set to true if you want to append to an existing file
* @param pollingInterval The polling interval in milliseconds.
*
* @throws KettleException in case the specified log file can't be created.
*/
public LogChannelFileWriter(String logChannelId, FileObject logFile, boolean appending, int pollingInterval) throws KettleException {
this.logChannelId = logChannelId;
this.logFile = logFile;
this.appending = appending;
this.pollingInterval = pollingInterval;
active = new AtomicBoolean(false);
lastBufferLineNr = CentralLogStore.getLastBufferLineNr();
try {
logFileOutputStream = KettleVFS.getOutputStream(logFile, appending);
} catch(IOException e) {
throw new KettleException("There was an error while trying to open file '"+logFile+"' for writing", e);
}
}
示例13: addSource
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
private boolean addSource(String source) throws KettleException{
if(meta.isFileSource()){
try{
FileObject fileObject = KettleVFS.getFileObject(source);
data.files.addFile(fileObject);
if (data.files.nrOfFiles()==0){
logError(Messages.getString("OGRFileOutput.Log.Error.NoFilesSpecified"));
return false;
}
}catch(IOException e){
logError(Messages.getString("OGRFileOutput.Log.Error.UnableToCreateFileObject", source));
return false;
}
}else
data.cnxStrings.add(source);
return true;
}
示例14: exportResources
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
/**
* 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.
* 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...
//
// From : ${Internal.Transformation.Filename.Directory}/../foo/bar.data
// To : /home/matt/test/files/foo/bar.data
//
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$
}
}
示例15: exportResources
import org.pentaho.di.core.vfs.KettleVFS; //导入依赖的package包/类
/**
* 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.
* 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...
//
// From : ${Internal.Transformation.Filename.Directory}/../foo/bar.data
// To : /home/matt/test/files/foo/bar.data
//
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$
}
}