org.pentaho.di.repository
Class RepositoryDirectory

java.lang.Object
  extended by org.pentaho.di.repository.RepositoryDirectory
All Implemented Interfaces:
RepositoryDirectoryInterface, RepositoryObjectInterface

public class RepositoryDirectory
extends Object
implements RepositoryDirectoryInterface

This class defines the location of a transformation, job or schema in the repository. That means that it's just an extra parameter for recognizing a transformation, job or schema. It allows for sub-directories by linking back to itself. TODO: This class is referenced in a large amount of Interfaces. We should convert it into an interface.

Since:
09-nov-2004
Author:
Matt

Field Summary
static String DIRECTORY_SEPARATOR
           
 
Constructor Summary
RepositoryDirectory()
          Create an empty repository directory.
RepositoryDirectory(RepositoryDirectoryInterface parent, String directoryname)
          Create a new sub-directory in a certain other directory.
 
Method Summary
 void addSubdirectory(RepositoryDirectoryInterface subdir)
          Add a subdirectory to this directory.
 void clear()
           
 RepositoryDirectory findChild(String name)
           
 RepositoryDirectory findDirectory(ObjectId id_directory)
          Find the sub-directory with a certain ID
 RepositoryDirectory findDirectory(String path)
          Find a directory using the path to the directory with file.separator between the dir-names.
 RepositoryDirectory findDirectory(String[] path)
          Find the directory by following the path of strings
 RepositoryDirectoryInterface findRoot()
          Find the root of the directory tree starting from this directory.
 List<RepositoryDirectoryInterface> getChildren()
          Returns a list of child directories
 ObjectId[] getDirectoryIDs()
          Get all the directory-id in this directory and the subdirectories.
 String getName()
          Get the name of this directory...
 int getNrSubdirectories()
          Counts the number of subdirectories in this directory.
 ObjectId getObjectId()
          Get the database ID in the repository for this object.
 RepositoryDirectoryInterface getParent()
          get the parent directory for this directory.
 String getPath()
          Describe the complete path to ( and including) this directory, separated by the RepositoryDirectory.DIRECTORY_SEPARATOR property (slash).
 String[] getPathArray()
          Describe the complete path to ( and including) this directory, as an array of strings.
 String getPathObjectCombination(String transName)
           
 List<RepositoryElementMetaInterface> getRepositoryObjects()
          Returns a list of child files
 RepositoryDirectory getSubdirectory(int i)
          Get a subdirectory on a certain position.
 String getXML()
          Return the description of this directory & the subdirectories in XML.
 String getXML(int level)
           
 boolean isRoot()
          Check whether or not this is the root of the directory trees.
 boolean isVisible()
          If true, this directory should be shown in UIs.
 boolean loadXML(Node repdirnode)
          Load the directory & subdirectories from XML
 void setChildren(List<RepositoryDirectoryInterface> children)
          sets the list of child directories
 void setName(String directoryname)
          Set the directory name (rename)
 void setObjectId(ObjectId id)
          Set the database ID for this object in the repository.
 void setParent(RepositoryDirectoryInterface parent)
          Change the parent of this directory.
 void setRepositoryObjects(List<RepositoryElementMetaInterface> repositoryObjects)
          sets the list of child files
 void setVisible(boolean visible)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DIRECTORY_SEPARATOR

public static final String DIRECTORY_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

RepositoryDirectory

public RepositoryDirectory(RepositoryDirectoryInterface parent,
                           String directoryname)
Create a new sub-directory in a certain other directory.

Parameters:
parent - The directory to create the sub-directory in
directoryname - The name of the new directory.

RepositoryDirectory

public RepositoryDirectory()
Create an empty repository directory. With the name and parent set to empty, this is the root directory.

Method Detail

getChildren

public List<RepositoryDirectoryInterface> getChildren()
Description copied from interface: RepositoryDirectoryInterface
Returns a list of child directories

Specified by:
getChildren in interface RepositoryDirectoryInterface
Returns:
list of child directories

setChildren

public void setChildren(List<RepositoryDirectoryInterface> children)
Description copied from interface: RepositoryDirectoryInterface
sets the list of child directories

Specified by:
setChildren in interface RepositoryDirectoryInterface
Parameters:
children - list of child directories

getRepositoryObjects

public List<RepositoryElementMetaInterface> getRepositoryObjects()
Description copied from interface: RepositoryDirectoryInterface
Returns a list of child files

Specified by:
getRepositoryObjects in interface RepositoryDirectoryInterface
Returns:
list of child files

setRepositoryObjects

public void setRepositoryObjects(List<RepositoryElementMetaInterface> repositoryObjects)
Description copied from interface: RepositoryDirectoryInterface
sets the list of child files

Specified by:
setRepositoryObjects in interface RepositoryDirectoryInterface
Parameters:
repositoryObjects - list of child files

clear

public void clear()
Specified by:
clear in interface RepositoryDirectoryInterface

getObjectId

public ObjectId getObjectId()
Get the database ID in the repository for this object.

Specified by:
getObjectId in interface RepositoryObjectInterface
Returns:
the database ID in the repository for this object.

setObjectId

public void setObjectId(ObjectId id)
Set the database ID for this object in the repository.

Specified by:
setObjectId in interface RepositoryDirectoryInterface
Parameters:
id - the database ID for this object in the repository.

setParent

public void setParent(RepositoryDirectoryInterface parent)
Change the parent of this directory. (move directory)

Specified by:
setParent in interface RepositoryDirectoryInterface
Parameters:
parent - The new parent of this directory.

getParent

public RepositoryDirectoryInterface getParent()
get the parent directory for this directory.

Specified by:
getParent in interface RepositoryDirectoryInterface
Returns:
The parent directory of null if this is the root directory.

setName

public void setName(String directoryname)
Set the directory name (rename)

Specified by:
setName in interface RepositoryDirectoryInterface
Parameters:
directoryname - The new directory name

getName

public String getName()
Get the name of this directory...

Specified by:
getName in interface RepositoryObjectInterface
Returns:
the name of this directory

isRoot

public boolean isRoot()
Check whether or not this is the root of the directory trees. (default)

Specified by:
isRoot in interface RepositoryDirectoryInterface
Returns:
true if this is the root directory node. False if it is not.

getPath

public String getPath()
Describe the complete path to ( and including) this directory, separated by the RepositoryDirectory.DIRECTORY_SEPARATOR property (slash).

Specified by:
getPath in interface RepositoryDirectoryInterface
Returns:
The complete path to this directory.

getPathArray

public String[] getPathArray()
Describe the complete path to ( and including) this directory, as an array of strings.

Specified by:
getPathArray in interface RepositoryDirectoryInterface
Returns:
The complete path to this directory.

addSubdirectory

public void addSubdirectory(RepositoryDirectoryInterface subdir)
Add a subdirectory to this directory.

Specified by:
addSubdirectory in interface RepositoryDirectoryInterface
Parameters:
subdir - The subdirectory to add.

getNrSubdirectories

public int getNrSubdirectories()
Counts the number of subdirectories in this directory.

Specified by:
getNrSubdirectories in interface RepositoryDirectoryInterface
Returns:
The number of subdirectories

getSubdirectory

public RepositoryDirectory getSubdirectory(int i)
Get a subdirectory on a certain position.

Specified by:
getSubdirectory in interface RepositoryDirectoryInterface
Parameters:
i - The subdirectory position
Returns:
The subdirectory with on a certain position

findDirectory

public RepositoryDirectory findDirectory(String[] path)
Find the directory by following the path of strings

Specified by:
findDirectory in interface RepositoryDirectoryInterface
Parameters:
path - The path to the directory we're looking for.
Returns:
The directory if one can be found, null if no directory was found.

findDirectory

public RepositoryDirectory findDirectory(String path)
Find a directory using the path to the directory with file.separator between the dir-names.

Specified by:
findDirectory in interface RepositoryDirectoryInterface
Parameters:
path - The path to the directory
Returns:
The directory if one was found, null if nothing was found.

findChild

public RepositoryDirectory findChild(String name)
Specified by:
findChild in interface RepositoryDirectoryInterface

findDirectory

public RepositoryDirectory findDirectory(ObjectId id_directory)
Find the sub-directory with a certain ID

Specified by:
findDirectory in interface RepositoryDirectoryInterface
Parameters:
id_directory - the directory ID to look for.
Returns:
The RepositoryDirectory if the ID was found, null if nothing could be found.

getXML

public String getXML()
Return the description of this directory & the subdirectories in XML.

Returns:
The XML describing this directory.

getXML

public String getXML(int level)

loadXML

public boolean loadXML(Node repdirnode)
Load the directory & subdirectories from XML

Parameters:
repdirnode - The node in which the Repository directory information resides.
Returns:
True if all went well, false if an error occured.

getDirectoryIDs

public ObjectId[] getDirectoryIDs()
Get all the directory-id in this directory and the subdirectories.

Specified by:
getDirectoryIDs in interface RepositoryDirectoryInterface
Returns:
an array of all the directory id's (this directory & subdirectories)

findRoot

public RepositoryDirectoryInterface findRoot()
Find the root of the directory tree starting from this directory.

Specified by:
findRoot in interface RepositoryDirectoryInterface
Returns:
the root of the directory tree

toString

public String toString()
Overrides:
toString in class Object

getPathObjectCombination

public String getPathObjectCombination(String transName)
Specified by:
getPathObjectCombination in interface RepositoryDirectoryInterface

isVisible

public boolean isVisible()
Description copied from interface: RepositoryDirectoryInterface
If true, this directory should be shown in UIs. Not necessarily persisted. Each repository implementation decides whether to mark each directory as visible.

Specified by:
isVisible in interface RepositoryDirectoryInterface

setVisible

public void setVisible(boolean visible)