本文整理了Java中org.pentaho.di.repository.Repository.findDirectory
方法的一些代码示例,展示了Repository.findDirectory
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Repository.findDirectory
方法的具体详情如下:
包路径:org.pentaho.di.repository.Repository
类名称:Repository
方法名:findDirectory
暂无
代码示例来源:origin: pentaho/pentaho-kettle
@Override
public RepositoryDirectoryInterface findDirectory( ObjectId objectId ) throws KettleException {
return getDelegate().findDirectory( objectId );
}
代码示例来源:origin: pentaho/pentaho-kettle
@Override
public RepositoryDirectoryInterface findDirectory( String s ) throws KettleException {
return getDelegate().findDirectory( s );
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Checks if there is a duplicate folder in a given directory (i.e. hidden folder)
*
* @param parent - Parent directory
* @param name - Name of folder
* @return - true if the parent directory has a folder equal to name, false otherwise
*/
private boolean hasDupeFolder( String parent, String name ) {
try {
RepositoryDirectoryInterface rdi = getRepository().findDirectory( parent ).findChild( name );
return rdi != null;
} catch ( Exception e ) {
System.out.println( e );
}
return false;
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Checks if there is a duplicate file in a given directory (i.e. hidden file)
*
* @param path - Path to directory in which we are saving
* @param name - Name of file to save
* @param fileName - Possible duplicate file name
* @param override - True is user wants override file, false otherwise
* @return - true if a duplicate file is found, false otherwise
*/
private boolean hasDupeFile( String path, String name, String fileName, boolean override ) {
try {
RepositoryDirectoryInterface repositoryDirectoryInterface = getRepository().findDirectory( path );
EngineMetaInterface meta = getSpoon().getActiveMeta();
RepositoryObjectType type = "Trans".equals( meta.getFileType() )
? RepositoryObjectType.TRANSFORMATION : RepositoryObjectType.JOB;
if ( getRepository().exists( name, repositoryDirectoryInterface, type ) ) {
return !override || !name.equals( fileName );
}
} catch ( Exception e ) {
System.out.println( e );
}
return false;
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* PDI-10762 - Trans and TransMeta leak
*/
@Test
public void testLoggingObjectIsNotLeakInTrans() throws KettleException {
Repository rep = Mockito.mock( Repository.class );
RepositoryDirectoryInterface repInt = Mockito.mock( RepositoryDirectoryInterface.class );
Mockito.when(
rep.loadTransformation( Mockito.anyString(), Mockito.any( RepositoryDirectoryInterface.class ), Mockito
.any( ProgressMonitorListener.class ), Mockito.anyBoolean(), Mockito.anyString() ) ).thenReturn( meta );
Mockito.when( rep.findDirectory( Mockito.anyString() ) ).thenReturn( repInt );
Trans trans = new Trans( meta, rep, "junit", "junitDir", "fileName" );
assertEquals( "Log channel General assigned", LogChannel.GENERAL.getLogChannelId(), trans.log
.getLogChannelId() );
}
代码示例来源:origin: pentaho/pentaho-kettle
public void setName( String name ) throws Exception {
if ( getDirectory().getName().equalsIgnoreCase( name ) ) {
return;
}
rep.renameRepositoryDirectory( getDirectory().getObjectId(), null, name );
// Update the object reference so the new name is displayed
obj = rep.findDirectory( getObjectId() );
getParent().refresh();
}
代码示例来源:origin: pentaho/pentaho-kettle
Path path = Paths.get( entry.getResource() );
RepositoryDirectoryInterface directory =
repository.findDirectory( path.getParent().toString().replace( File.separator, "/" ) );
return convert(
repository.loadTransformation( path.getFileName().toString(), directory, null, true, null ) );
代码示例来源:origin: pentaho/pentaho-kettle
private RepositoryDirectoryInterface getTargetDirectory( String directoryPath, String dirOverride,
RepositoryImportFeedbackInterface feedback ) throws KettleException {
if ( directoryPath.isEmpty() ) {
return baseDirectory;
}
RepositoryDirectoryInterface targetDirectory = null;
if ( dirOverride != null ) {
targetDirectory = rep.findDirectory( directoryPath );
if ( targetDirectory == null ) {
feedback.addLog( BaseMessages.getString( PKG, "RepositoryImporter.CreateDir.Log", directoryPath,
getRepositoryRoot().toString() ) );
targetDirectory = rep.createRepositoryDirectory( getRepositoryRoot(), directoryPath );
}
} else {
targetDirectory = baseDirectory.findDirectory( directoryPath );
if ( targetDirectory == null ) {
feedback.addLog( BaseMessages.getString( PKG, "RepositoryImporter.CreateDir.Log", directoryPath, baseDirectory
.toString() ) );
targetDirectory = rep.createRepositoryDirectory( baseDirectory, directoryPath );
}
}
return targetDirectory;
}
代码示例来源:origin: pentaho/pentaho-kettle
@Test
@PrepareForTest( StepWithMappingMeta.class )
public void testFileNameAsVariable() throws Exception {
String transName = "test.ktr";
String transDirectory = "/admin";
String transNameVar = "transName";
String transDirectoryVar = "transDirectory";
VariableSpace parent = new Variables();
parent.setVariable( transNameVar, transName );
parent.setVariable( transDirectoryVar, transDirectory );
StepMeta stepMeta = new StepMeta();
TransMeta parentTransMeta = new TransMeta();
stepMeta.setParentTransMeta( parentTransMeta );
StepWithMappingMeta mappingMetaMock = mock( StepWithMappingMeta.class );
Mockito.when( mappingMetaMock.getSpecificationMethod() ).thenReturn( ObjectLocationSpecificationMethod.FILENAME );
Mockito.when( mappingMetaMock.getFileName() ).thenReturn( "${" + transDirectoryVar + "}/${" + transNameVar + "}" );
Mockito.when( mappingMetaMock.getParentStepMeta() ).thenReturn( stepMeta );
Repository rep = mock( Repository.class );
RepositoryDirectoryInterface directoryInterface = Mockito.mock( RepositoryDirectoryInterface.class );
Mockito.doReturn( directoryInterface ).when( rep ).findDirectory( anyString() );
Mockito.doReturn( new TransMeta() ).when( rep )
.loadTransformation( anyString(), any(), any(), anyBoolean(), any() );
TransMeta transMeta = StepWithMappingMeta.loadMappingMeta( mappingMetaMock, rep, null, parent, true );
Assert.assertNotNull( transMeta );
Mockito.verify( rep, Mockito.times( 1 ) ).findDirectory( Mockito.eq( transDirectory ) );
Mockito.verify( rep, Mockito.times( 1 ) ).loadTransformation( Mockito.eq( transName ),
Mockito.eq( directoryInterface ), Mockito.eq( null ), Mockito.eq( true ), Mockito.eq( null ) );
}
代码示例来源:origin: pentaho/pentaho-kettle
@Test
public void testIncludesSubTransformationsFromRepository() throws Exception {
TransMeta parentTransMeta = new TransMeta( getClass().getResource( "trans-meta-converter-parent.ktr" ).getPath() );
Repository repository = mock( Repository.class );
TransMeta transMeta = new TransMeta( );
RepositoryDirectoryInterface repositoryDirectory = new RepositoryDirectory( null, "public");
String directory = getClass().getResource( "" ).toString().replace( File.separator, "/" );
when( repository.findDirectory( "public" ) ).thenReturn( repositoryDirectory );
when( repository.loadTransformation( "trans-meta-converter-sub.ktr", repositoryDirectory, null, true, null ) ).thenReturn( transMeta );
parentTransMeta.setRepository( repository );
parentTransMeta.setRepositoryDirectory( repositoryDirectory );
parentTransMeta.setVariable( "Internal.Entry.Current.Directory", "public" );
Transformation transformation = TransMetaConverter.convert( parentTransMeta );
@SuppressWarnings( { "unchecked", "ConstantConditions" } )
HashMap<String, Transformation> config =
(HashMap<String, Transformation>) transformation.getConfig( TransMetaConverter.SUB_TRANSFORMATIONS_KEY ).get();
assertEquals( 1, config.size() );
assertNotNull( config.get( "public/trans-meta-converter-sub.ktr" ) );
}
代码示例来源:origin: pentaho/pentaho-kettle
RepositoryDirectory repDirectory =
new RepositoryDirectory( new RepositoryDirectory( new RepositoryDirectory(), "home" ), "admin" );
Mockito.when( rep.findDirectory( Mockito.eq( directory ) ) ).thenReturn( repDirectory );
TransMeta meta = new TransMeta();
代码示例来源:origin: pentaho/pentaho-kettle
RepositoryDirectory repDirectory =
new RepositoryDirectory( new RepositoryDirectory( new RepositoryDirectory(), "home" ), "admin" );
Mockito.when( rep.findDirectory( Mockito.eq( directory ) ) ).thenReturn( repDirectory );
JobMeta meta = new JobMeta();
代码示例来源:origin: pentaho/pentaho-kettle
return null;
} ).when( rep ).findDirectory( anyString() );
代码示例来源:origin: pentaho/pentaho-kettle
BaseMessages.getString( PKG, "TransExecutorDialog.Exception.NoValidMappingDetailsFound" ) );
RepositoryDirectoryInterface repdir = repository.findDirectory( realDirectory );
if ( repdir == null ) {
throw new KettleException( BaseMessages.getString(
代码示例来源:origin: pentaho/pentaho-kettle
final RepositoryDirectoryInterface rdi = rep.findDirectory( lastUsedFile.getDirectory() );
if ( rdi == null ) {
return false;
代码示例来源:origin: pentaho/pentaho-kettle
Mockito.doReturn( Mockito.mock( RepositoryDirectoryInterface.class ) ).when( rep ).findDirectory( anyString() );
代码示例来源:origin: pentaho/pentaho-kettle
public UIRepositoryDirectory createFolder( String name ) throws Exception {
RepositoryDirectoryInterface thisDir = getDirectory();
RepositoryDirectoryInterface dir;
//PDI-5202: the directory might exist already. If so, don't create a new one.
String dirName = checkDirNameExistsInRepo( name );
if ( dirName == null ) {
dir = rep.createRepositoryDirectory( thisDir, name );
} else {
dir = rep.findDirectory( thisDir.getPath() + "/" + dirName );
}
UIRepositoryDirectory newDir = null;
try {
newDir = UIObjectRegistry.getInstance().constructUIRepositoryDirectory( dir, this, rep );
} catch ( UIObjectCreationException uoe ) {
newDir = new UIRepositoryDirectory( dir, this, rep );
}
UIRepositoryDirectories directories = getChildren();
if ( !contains( directories, newDir ) ) {
directories.add( newDir );
} else {
throw new KettleException( "Unable to create folder with the same name [" + name + "]" );
}
kidElementCache = null; // rebuild the element cache for correct positioning.
return newDir;
}
代码示例来源:origin: pentaho/pentaho-kettle
@Override public void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ) throws KettleException {
FileDialogOperation fileDialogOperation = (FileDialogOperation) o;
PropsUI propsUI = propsUISupplier.get();
String startingDir = null;
if ( fileDialogOperation.getRepository() == null ) {
String username = getRepository().getUserInfo() != null ? getRepository().getUserInfo().getLogin() : "";
String repoAndUser = getRepository().getName() + ":" + username;
List<LastUsedFile> lastUsedFileList =
propsUI.getLastUsedRepoFiles().getOrDefault( repoAndUser, Collections.emptyList() );
startingDir = getStartingDir( fileDialogOperation, lastUsedFileList );
} else {
startingDir = fileDialogOperation.getStartDir();
}
RepositoryOpenSaveDialog repositoryOpenSaveDialog =
new RepositoryOpenSaveDialog( spoonSupplier.get().getShell(), WIDTH, HEIGHT );
repositoryOpenSaveDialog.open( fileDialogOperation.getRepository(), startingDir, fileDialogOperation.getCommand(),
fileDialogOperation.getTitle(), fileDialogOperation.getFilter(), fileDialogOperation.getOrigin(),
fileDialogOperation.getFilename(), fileDialogOperation.getFileType() );
if ( !Utils.isEmpty( repositoryOpenSaveDialog.getObjectName() ) ) {
RepositoryObject repositoryObject = new RepositoryObject();
repositoryObject.setObjectId( repositoryOpenSaveDialog::getObjectId );
repositoryObject.setName( repositoryOpenSaveDialog.getObjectName() );
repositoryObject
.setRepositoryDirectory( getRepository().findDirectory( repositoryOpenSaveDialog.getObjectDirectory() ) );
repositoryObject.setObjectType(
repositoryOpenSaveDialog.getObjectType().equals( TRANSFORMATION ) ? RepositoryObjectType.TRANSFORMATION
: RepositoryObjectType.JOB );
fileDialogOperation.setRepositoryObject( repositoryObject );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
RepositoryDirectoryInterface rootDir = repo.findDirectory( "/" );
代码示例来源:origin: pentaho/pentaho-kettle
try {
if ( rep != null ) {
RepositoryDirectoryInterface repdir = rep.findDirectory( dirname );
if ( repdir != null ) {
this.transMeta = rep.loadTransformation( name, repdir, null, false, null ); // reads last version
内容来源于网络,如有侵权,请联系作者删除!