public String calcRelativeElementDirectory( RepositoryDirectoryInterface dir ) { if ( dir != null ) { return dir.getPath(); } else { return "/"; } }
private RepositoryDirectoryInterface findDirectory( String path ) { return rootDirectory.findDirectory( path ); }
public static RepositoryDirectory build( String parentPath, RepositoryDirectoryInterface repositoryDirectoryInterface ) { RepositoryDirectory repositoryDirectory = new RepositoryDirectory(); repositoryDirectory.setParent( parentPath ); repositoryDirectory.setName( repositoryDirectoryInterface.getName() ); repositoryDirectory.setPath( repositoryDirectoryInterface.getPath() ); repositoryDirectory.setObjectId( repositoryDirectoryInterface.getObjectId() ); repositoryDirectory.setHidden( !repositoryDirectoryInterface.isVisible() ); return repositoryDirectory; }
private RepositoryDirectoryInterface copyFrom( RepositoryDirectoryInterface folders, RepositoryDirectoryInterface withFiles ) { if ( folders.getName().equals( withFiles.getName() ) ) { for ( RepositoryDirectoryInterface dir2 : withFiles.getChildren() ) { for ( RepositoryDirectoryInterface dir1 : folders.getChildren() ) { copyFrom( dir1, dir2 ); } } folders.setRepositoryObjects( withFiles.getRepositoryObjects() ); } return folders; }
@Override public String[] getDirectoryNames( ObjectId id_directory ) throws KettleException { RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree(); RepositoryDirectoryInterface directory = tree.findDirectory( id_directory ); String[] names = new String[directory.getNrSubdirectories()]; for ( int i = 0; i < names.length; i++ ) { names[i] = directory.getSubdirectory( i ).getName(); } return names; }
public void saveRepositoryDirectory( RepositoryDirectoryInterface dir ) throws KettleException { try { ObjectId id_directory_parent = null; if ( dir.getParent() != null ) { id_directory_parent = dir.getParent().getObjectId(); } dir.setObjectId( insertDirectory( id_directory_parent, dir ) ); log.logDetailed( "New id of directory = " + dir.getObjectId() ); repository.commit(); } catch ( Exception e ) { throw new KettleException( "Unable to save directory [" + dir + "] in the repository", e ); } }
ObjectId[] dirids = dirTree.getDirectoryIDs(); log.logDebug( BaseMessages.getString( PKG, "Repository.Exporter.Log.DirectoryGoing", dirids.length, dirTree .getPath() ) ); break; RepositoryDirectoryInterface repdir = dirTree.findDirectory( dirids[d] ); String[] jobs = repository.getJobNames( dirids[d], false ); log.logDebug( BaseMessages.getString( PKG, "Repository.Exporter.Log.FindJobs", jobs.length, repdir.getName() ) ); String dirPath = repdir.getPath();
@Override public ObjectId renameRepositoryDirectory( ObjectId id, RepositoryDirectoryInterface newParentDir, String newName ) throws KettleException { if ( newParentDir != null || newName != null ) { try { // In case of a root object, the ID is the same as the relative filename... RepositoryDirectoryInterface tree = loadRepositoryDirectoryTree(); RepositoryDirectoryInterface dir = tree.findDirectory( id ); if ( dir == null ) { throw new KettleException( "Could not find folder [" + id + "]" ); } // If newName is null, keep the current name newName = ( newName != null ) ? newName : dir.getName(); FileObject folder = KettleVFS.getFileObject( dir.getPath() ); String newFolderName = null; if ( newParentDir != null ) { FileObject newParentFolder = KettleVFS.getFileObject( newParentDir.getPath() ); newFolderName = newParentFolder.toString() + "/" + newName; } else { newFolderName = folder.getParent().toString() + "/" + newName; } FileObject newFolder = KettleVFS.getFileObject( newFolderName ); folder.moveTo( newFolder ); return new StringObjectId( dir.getObjectId() ); } catch ( Exception e ) { throw new KettleException( "Unable to rename directory folder to [" + id + "]" ); } } return ( id ); }
if ( parentDirectory.isRoot() && ( directoryPath.equals( Import.ROOT_DIRECTORY ) RepositoryDirectoryInterface refreshedParentDir = findDirectory( parentDirectory.getPath() ); parentDirectory.setChildren( refreshedParentDir.getChildren() ); String[] path = Const.splitPath( directoryPath, RepositoryDirectory.DIRECTORY_SEPARATOR ); RepositoryDirectoryInterface child = follow.findChild( path[level] ); if ( child == null ) { saveRepositoryDirectory( child ); follow.addSubdirectory( child );
TreeItem ti = wTree.getSelection()[ 0 ]; String[] str = ConstUI.getTreeStrings( ti ); RepositoryDirectoryInterface dir = repositoryTree.findDirectory( str ); if ( dir != null ) { String oldName = dir.getName(); EnterStringDialog etd = new EnterStringDialog( shell, oldName, String newName = etd.open(); if ( newName != null && !newName.equals( oldName ) ) { dir.setName( newName ); try { rep.renameRepositoryDirectory( dir.getObjectId(), dir.getParent(), newName ); ti.setText( newName ); wTree.setSelection( ti );
root.setName( "/" ); RepositoryDirectoryInterface subdir1 = new RepositoryDirectory( root, "subdir1" ); RepositoryDirectoryInterface subdir2 = new RepositoryDirectory( subdir1, "subdir2" ); list2.add( job2 ); subdir1.setRepositoryObjects( list1 ); subdir2.setRepositoryObjects( list2 ); subdir1.addSubdirectory( subdir2 ); root.addSubdirectory( subdir1 ); } else if ( actualPath.equals( subdir1.getPath() ) ) { return subdir1; } else if ( actualPath.equals( subdir2.getPath() ) ) { return subdir2; } else {
if ( log.isDetailed() ) { log.logDetailed( BaseMessages.getString( PKG, "Spoon.Log.LoadToTransformation", objName, repDir .getName() ) ); props.addLastFile( LastUsedFile.FILE_TYPE_TRANSFORMATION, objName, repDir.getPath(), true, rep.getName(), getUsername(), null ); addMenuLast(); jobMeta.clearChanged(); if ( jobMeta != null ) { props.addLastFile( LastUsedFile.FILE_TYPE_JOB, objName, repDir.getPath(), true, rep.getName(), getUsername(), null ); saveSettings();
public RepositoryDirectory create( String parent, String name ) { if ( hasDupeFolder( parent, name ) ) { return null; } try { RepositoryDirectoryInterface repositoryDirectoryInterface = getRepository().createRepositoryDirectory( findDirectory( parent ), name ); RepositoryDirectory repositoryDirectory = new RepositoryDirectory(); repositoryDirectory.setName( repositoryDirectoryInterface.getName() ); repositoryDirectory.setPath( repositoryDirectoryInterface.getPath() ); repositoryDirectory.setObjectId( repositoryDirectoryInterface.getObjectId() ); repositoryDirectory.setParent( parent ); return repositoryDirectory; } catch ( Exception e ) { return null; } }
@Override public void saveRepositoryDirectory( final RepositoryDirectoryInterface dir ) throws KettleException { // id of root dir is null--check for it if ( "/".equals( dir.getParent().getName() ) ) { throw new KettleException( BaseMessages.getString( PKG, "PurRepository.FailedDirectoryCreation.Message" ) ); } readWriteLock.writeLock().lock(); try { RepositoryFile newFolder = pur.createFolder( dir.getParent().getObjectId() != null ? dir.getParent().getObjectId().getId() : null, new RepositoryFile.Builder( dir.getName() ).folder( true ).build(), null ); dir.setObjectId( new StringObjectId( newFolder.getId().toString() ) ); } catch ( Exception e ) { throw new KettleException( "Unable to save repository directory with path [" + getPath( null, dir, null ) + "]", e ); } finally { readWriteLock.writeLock().unlock(); } }
public static RepositoryDirectoryInterface chooseDirectory( Shell shell, Repository rep, RepositoryDirectoryInterface directoryFrom ) { if ( rep == null ) { return null; } if ( directoryFrom == null ) { try { directoryFrom = rep.getUserHomeDirectory(); } catch ( KettleException ex ) { directoryFrom = new RepositoryDirectory(); } } ObjectId idDirectoryFrom = directoryFrom.getObjectId(); SelectDirectoryDialog sdd = new SelectDirectoryDialog( shell, SWT.NONE, rep ); //PDI-13867: root dir and its direct subdirectories are restricted. HashSet<String> restrictedPaths = new HashSet<String>(); restrictedPaths.add( directoryFrom.findRoot().getPath() ); restrictedPaths.add( "/home" ); sdd.setRestrictedPaths( restrictedPaths ); //TODO: expand and select directoryFrom in the dialog. RepositoryDirectoryInterface rd = sdd.open(); if ( rd == null || idDirectoryFrom == rd.getObjectId() ) { return null; } return rd; }
/** * Describe the complete path to ( and including) this directory, separated by the * RepositoryDirectory.DIRECTORY_SEPARATOR property (slash). * * @return The complete path to this directory. */ @Override public String getPath() { // Root! if ( getParent() == null ) { return DIRECTORY_SEPARATOR; } else { if ( getParent().getParent() == null ) { return DIRECTORY_SEPARATOR + getName(); } else { return getParent().getPath() + DIRECTORY_SEPARATOR + getName(); } } }
public void printRepositoryDirectories( Repository repository, RepositoryDirectoryInterface directory ) throws KettleException { String[] directories = repository.getDirectoryNames( directory.getObjectId() ); if ( directories != null ) { for ( String dir : directories ) { System.out.println( dir ); } } }
/** * Gets the repository directory path and name of the transformation. * * @return The repository directory path plus the name of the transformation */ public String getPathAndName() { if ( getRepositoryDirectory().isRoot() ) { return getRepositoryDirectory().getPath() + getName(); } else { return getRepositoryDirectory().getPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + getName(); } }
protected static List<RepositoryElementMetaInterface> loadRepositoryObjects( RepositoryDirectoryInterface dir, boolean getTransformations, boolean getJobs, Repository rep ) throws KettleDatabaseException { // Then show the transformations & jobs in that directory... List<RepositoryElementMetaInterface> repositoryObjects = new ArrayList<RepositoryElementMetaInterface>(); if ( dir.getRepositoryObjects() == null ) { try { dir.setRepositoryObjects( rep.getJobAndTransformationObjects( dir.getObjectId(), false ) ); } catch ( KettleException e ) { throw new KettleDatabaseException( e ); } } List<RepositoryObjectType> allowedTypes = new ArrayList<>( 2 ); if ( getTransformations ) { allowedTypes.add( RepositoryObjectType.TRANSFORMATION ); } if ( getJobs ) { allowedTypes.add( RepositoryObjectType.JOB ); } for ( RepositoryElementMetaInterface repoObject : dir.getRepositoryObjects() ) { if ( allowedTypes.contains( repoObject.getObjectType() ) ) { repositoryObjects.add( repoObject ); } } return repositoryObjects; }
boolean includeDeleted, boolean ascending, boolean getTransformations, boolean getJobs, RepositoryDirectoryInterface dir, String filterString, Pattern pattern ) throws KettleDatabaseException { ti.setText( dir.getName() ); ti.setData( dir ); ti.setData( "isFolder", true ); List<RepositoryDirectoryInterface> children = dir.getChildren(); Collections.sort( children, new Comparator<RepositoryDirectoryInterface>() { @Override ti.setExpanded( dir.isRoot() );