本文整理汇总了Java中org.pentaho.di.core.vfs.KettleVFS.getFileObject方法的典型用法代码示例。如果您正苦于以下问题:Java KettleVFS.getFileObject方法的具体用法?Java KettleVFS.getFileObject怎么用?Java KettleVFS.getFileObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.vfs.KettleVFS
的用法示例。
在下文中一共展示了KettleVFS.getFileObject方法的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...
//
// From : ${Internal.Transformation.Filename.Directory}/../foo/bar.txt
// To : /home/matt/test/files/foo/bar.txt
//
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 = fileObject.getName().getPath();
return filename;
}
return null;
} catch (Exception e) {
throw new KettleException(e); //$NON-NLS-1$
}
}
示例2: 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;
}
示例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 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$
}
}
示例4: 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$
}
}
示例5: 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...
//
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$
}
}
示例6: 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...
//
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$
}
}
示例7: 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$
}
}
示例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.
* HANDLER: 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), 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$
}
}
示例9: getJobObjects
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
public List<RepositoryElementMetaInterface> getJobObjects(ObjectId id_directory, boolean includeDeleted) throws KettleException {
try {
List<RepositoryElementMetaInterface> list = new ArrayList<RepositoryElementMetaInterface>();
RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree();
RepositoryDirectoryInterface directory = tree.findDirectory(id_directory);
String folderName = calcDirectoryName(directory);
FileObject folder = KettleVFS.getFileObject(folderName);
for (FileObject child : folder.getChildren()) {
if (child.getType().equals(FileType.FILE)) {
if (!child.isHidden() || !repositoryMeta.isHidingHiddenFiles()) {
String name = child.getName().getBaseName();
if (name.endsWith(EXT_JOB)) {
String jobName = name.substring(0, name.length()-4);
ObjectId id = new StringObjectId(calcObjectId(directory, jobName, EXT_JOB));
Date date = new Date(child.getContent().getLastModifiedTime());
list.add( new RepositoryObject(id, jobName, directory, "-", date, RepositoryObjectType.JOB, "", false) );
}
}
}
}
return list;
}
catch(Exception e) {
throw new KettleException("Unable to get list of jobs in folder with id : "+id_directory, e);
}
}
示例10: getFiles
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
private List<FileObject> getFiles(String localfolder) throws KettleFileException
{
try {
List<FileObject> myFileList = new ArrayList<FileObject>();
// Get all the files in the local directory...
FileObject localFiles = KettleVFS.getFileObject(localfolder, this);
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;
} catch(IOException e) {
throw new KettleFileException(e);
}
}
示例11: addFileToResultFilenames
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
private void addFileToResultFilenames(String fileaddentry, Result result,Job parentJob)
{
try{
ResultFile resultFile = new ResultFile(ResultFile.FILE_TYPE_GENERAL, KettleVFS.getFileObject(fileaddentry, this), parentJob.getJobname(), toString());
result.getResultFiles().put(resultFile.getFile().toString(), resultFile);
if(log.isDebug()){
logDebug(" ------ ");
logDebug(BaseMessages.getString(PKG, "JobEntryMSAccessBulkLoad.Log.FileAddedToResultFilesName",fileaddentry));
}
}catch (Exception e){
log.logError(BaseMessages.getString(PKG, "JobEntryMSAccessBulkLoad.Error.AddingToFilenameResult"),fileaddentry + ""+e.getMessage());
}
}
示例12: setInternalKettleVariables
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
public void setInternalKettleVariables(VariableSpace var)
{
if (transMeta != null && !Const.isEmpty(transMeta.getFilename())) // we have a finename that's defined.
{
try
{
FileObject fileObject = KettleVFS.getFileObject(transMeta.getFilename());
FileName fileName = fileObject.getName();
// The filename of the transformation
variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, fileName.getBaseName());
// The directory of the transformation
FileName fileDir = fileName.getParent();
variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, fileDir.getURI());
}
catch(IOException e)
{
variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, "");
variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, "");
}
}
else
{
variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_DIRECTORY, "");
variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_FILENAME_NAME, "");
}
// The name of the transformation
variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_NAME, Const.NVL(transMeta.getName(), ""));
// TODO PUT THIS INSIDE OF THE "IF"
// The name of the directory in the repository
variables.setVariable(Const.INTERNAL_VARIABLE_TRANSFORMATION_REPOSITORY_DIRECTORY, transMeta.getDirectory()!=null?transMeta.getDirectory().getPath():"");
// Here we don't clear the definition of the job specific parameters, as they may come in handy.
// A transformation can be called from a job and may inherit the job internal variables
// but the other around is not possible.
}
示例13: loadNodeFromXML
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
public Node loadNodeFromXML(ObjectId id, String tag) throws KettleException {
try {
// The object ID is the base name of the file in the Base directory folder
//
String filename = calcDirectoryName(null)+id.getId();
FileObject fileObject = KettleVFS.getFileObject(filename);
Document document = XMLHandler.loadXMLFile(fileObject);
Node node = XMLHandler.getSubNode(document, tag);
return node;
}
catch(Exception e) {
throw new KettleException("Unable to load XML object from object with ID ["+id+"] and tag ["+tag+"]", e);
}
}
示例14: validate
import org.pentaho.di.core.vfs.KettleVFS; //导入方法依赖的package包/类
public boolean validate(CheckResultSourceInterface source, String propertyName, List<CheckResultInterface> remarks,
ValidatorContext context)
{
String filename = ValidatorUtils.getValueAsString(source, propertyName);
VariableSpace variableSpace = getVariableSpace(source, propertyName, remarks, context);
boolean failIfExists = getFailIfExists(source, propertyName, remarks, context);
if (null == variableSpace)
{
return false;
}
String realFileName = variableSpace.environmentSubstitute(filename);
FileObject fileObject = null;
try
{
fileObject = KettleVFS.getFileObject(realFileName, variableSpace);
if (fileObject.exists() && failIfExists)
{
JobEntryValidatorUtils.addFailureRemark(source, propertyName, VALIDATOR_NAME, remarks, JobEntryValidatorUtils
.getLevelOnFail(context, VALIDATOR_NAME));
return false;
}
try
{
fileObject.close(); // Just being paranoid
} catch (IOException ignored)
{
}
} catch (Exception e)
{
JobEntryValidatorUtils.addExceptionRemark(source, propertyName, VALIDATOR_NAME, remarks, e);
return false;
}
return true;
}
示例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...
// 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), 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$
}
}