public void populateChildren() { if ( kidDirectoryCache == null || !populated ) { kidDirectoryCache = new UIRepositoryDirectories(); } for ( RepositoryDirectoryInterface child : rd.getChildren() ) { try { kidDirectoryCache.add( UIObjectRegistry.getInstance().constructUIRepositoryDirectory( child, this, rep ) ); } catch ( UIObjectCreationException e ) { kidDirectoryCache.add( new UIRepositoryDirectory( child, this, rep ) ); } } populated = true; }
@Override public UIRepositoryDirectory sourceToTarget( final UIRepositoryDirectory value ) { if ( value == null || value.size() == 0 ) { return null; } if ( !value.get( value.size() - 1 ).equals( trashDir ) ) { // add directly to children collection to bypass events value.getChildren().add( trashDir ); } return value; }
public UIRepositoryDirectories getChildren() { if ( kidDirectoryCache == null ) { kidDirectoryCache = new UIRepositoryDirectories(); if ( getParent() != null ) { RepositoryDirectory repositoryDirectory = new RepositoryDirectory(); repositoryDirectory.setObjectId( null ); UIRepositoryDirectory uiRepositoryDirectory = new UIRepositoryDirectory( repositoryDirectory, null, null ); kidDirectoryCache.add( uiRepositoryDirectory ); } } return kidDirectoryCache; }
@Override public void move( UIRepositoryDirectory newParentDir ) throws Exception { if ( newParentDir != null ) { rep.renameRepositoryDirectory( obj.getObjectId(), newParentDir.getDirectory(), null ); // Try to make sure the directories are updated properly if ( !newParentDir.equals( getParent() ) ) { getParent().getChildren().remove( this ); newParentDir.getChildren().add( this ); getParent().refresh(); newParentDir.refresh(); } } }
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; }