当前位置: 首页>>代码示例>>Java>>正文


Java KettleVFS.getFileObject方法代码示例

本文整理汇总了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$
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:33,代码来源:FixedInputMeta.java

示例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;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:21,代码来源:KettleFileRepository.java

示例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$
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:31,代码来源:PropertyOutputMeta.java

示例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$
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:24,代码来源:LDIFInputMeta.java

示例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$
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:20,代码来源:ExcelOutputMeta.java

示例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$
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:21,代码来源:XMLOutputMeta.java

示例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$
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:32,代码来源:CubeInputMeta.java

示例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$
  }
}
 
开发者ID:carbondata,项目名称:carbondata,代码行数:40,代码来源:CsvInputMeta.java

示例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);
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:35,代码来源:KettleFileRepository.java

示例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);
 	}
 
 }
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:29,代码来源:JobEntrySSH2PUT.java

示例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());
	}
  }
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:15,代码来源:JobEntryMSAccessBulkLoad.java

示例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.
    
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:41,代码来源:Trans.java

示例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);
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:16,代码来源:KettleFileRepository.java

示例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;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:39,代码来源:FileDoesNotExistValidator.java

示例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$
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:35,代码来源:CsvInputMeta.java


注:本文中的org.pentaho.di.core.vfs.KettleVFS.getFileObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。