com.buildforge.services.client.dbo
Class Environment

java.lang.Object
  extended by com.buildforge.services.client.dbo.Environment

public final class Environment
extends java.lang.Object

Represents a set of name/value pairs used to form the final environment settings for a Build. Environments may be assigned to Projects, Servers, and Steps. Each name/value pair is represented by a child EnvironmentEntry.


Field Summary
static java.lang.Class<Environment> CLASS
           
 
Constructor Summary
Environment(APIClientConnection conn)
           
 
Method Summary
 void addEntry(EnvironmentEntry newEntry)
          Add a new Entry to this Environment (at the end of the list)
 void addEntry(EnvironmentEntry newEntry, int index)
          Add a new Entry to this Environment, at the specified, 0-based index
 Environment clone()
          Clones this Environment, complete with related EnvironmentEntries (also cloned), but clears the environment group id of the cloned object making it ready for a .create() call.
 EnvironmentEntry copyEntry(int fromIndex)
          Copies the specified property from a specified.
 Environment copyEntry(int fromIndex, int toIndex)
          Copies the specified property into a new position in the property list
 Environment create()
          Creates a new Environment in the database, including any related Environment Entries related to this Environment.
 void delete()
          Removes this Environment, and all related Environment Entries from the database
static java.util.List<Environment> findAll(APIClientConnection conn)
          Returns the list of all Environments in the system.
static Environment findById(APIClientConnection conn, int envGroupId)
          Retrieves the specified environment by envionment group id
static Environment findByName(APIClientConnection conn, java.lang.String environmentName)
          Retrieves the specified environment by envionment group name
 java.util.List<EnvironmentEntry> getEntries()
          Returns the List of Entries currently associated with this Environment
 EnvironmentEntry getEntry(int index)
          Retrieves an Entry by 0-based index
 EnvironmentEntry getEntry(java.lang.String parameterName)
          Retrieves an Entry by parameter name, or null if no Entry matches
 int getEnvGroupId()
          Returns the Environment Group Identifier
 int getLevel()
          Returns the security level associated with this Envionment
 java.lang.String getName()
          Returns the pretty name of this Environment
 Environment moveEntry(int fromIndex, int toIndex)
          Moves an entry from one 0-based index to another.
 EnvironmentEntry removeEntry(int index)
          Removes an Entry by 0-based index
 EnvironmentEntry removeEntry(java.lang.String parameterName)
          Removes an Entry by parameter name
 void setLevel(int level)
          Sets the security level the will be associated with this Environment
 void setName(java.lang.String name)
          Sets the pretty name of this Environment
 java.lang.String toString()
           
 Environment update()
          Commits changes to this Environment only, not any related Environment Entries, to the database
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS

public static final java.lang.Class<Environment> CLASS
Constructor Detail

Environment

public Environment(APIClientConnection conn)
Method Detail

findAll

public static java.util.List<Environment> findAll(APIClientConnection conn)
                                           throws java.io.IOException,
                                                  ServiceException
Returns the list of all Environments in the system. All objects will be returned without child properties. To retrieve these properties, use findById(APIClientConnection conn, int envId)

Parameters:
conn -
Returns:
a list of environment blocks
Throws:
java.io.IOException
ServiceException

findById

public static Environment findById(APIClientConnection conn,
                                   int envGroupId)
                            throws java.io.IOException,
                                   ServiceException
Retrieves the specified environment by envionment group id

Parameters:
conn -
envGroupId -
Returns:
Throws:
java.io.IOException
ServiceException

findByName

public static Environment findByName(APIClientConnection conn,
                                     java.lang.String environmentName)
                              throws java.io.IOException,
                                     ServiceException
Retrieves the specified environment by envionment group name

Parameters:
conn -
environmentName -
Returns:
Throws:
java.io.IOException
ServiceException

create

public Environment create()
                   throws java.io.IOException,
                          ServiceException
Creates a new Environment in the database, including any related Environment Entries related to this Environment.

Returns:
Throws:
java.io.IOException
ServiceException - If the Environment already exists in the database

update

public Environment update()
                   throws java.io.IOException,
                          ServiceException
Commits changes to this Environment only, not any related Environment Entries, to the database

Returns:
Throws:
java.io.IOException
ServiceException - If this Environment does not already exist in the database

delete

public void delete()
            throws java.io.IOException,
                   ServiceException
Removes this Environment, and all related Environment Entries from the database

Throws:
java.io.IOException
ServiceException - If this Environment does not already exist in the database

addEntry

public void addEntry(EnvironmentEntry newEntry)
              throws java.io.IOException,
                     ServiceException
Add a new Entry to this Environment (at the end of the list)

Parameters:
newEntry -
Throws:
java.io.IOException
ServiceException

addEntry

public void addEntry(EnvironmentEntry newEntry,
                     int index)
              throws java.io.IOException,
                     ServiceException
Add a new Entry to this Environment, at the specified, 0-based index

Parameters:
newEntry -
index -
Throws:
java.io.IOException
ServiceException

removeEntry

public EnvironmentEntry removeEntry(java.lang.String parameterName)
                             throws java.io.IOException,
                                    ServiceException
Removes an Entry by parameter name

Parameters:
parameterName -
Throws:
java.io.IOException
ServiceException

removeEntry

public EnvironmentEntry removeEntry(int index)
                             throws java.io.IOException,
                                    ServiceException
Removes an Entry by 0-based index

Parameters:
index -
Throws:
java.io.IOException
ServiceException

moveEntry

public Environment moveEntry(int fromIndex,
                             int toIndex)
                      throws java.io.IOException,
                             ServiceException
Moves an entry from one 0-based index to another.

Parameters:
fromIndex - the index to move from
toIndex - the index before which to move the Entry to, 0 for head of the list
Throws:
java.io.IOException
ServiceException

copyEntry

public EnvironmentEntry copyEntry(int fromIndex)
                           throws ServiceException
Copies the specified property from a specified. 0-based index and returns the object for possible addition to another, unique Environment

Parameters:
fromIndex -
Returns:
The newly copied EnvironmentEntry
Throws:
ServiceException

copyEntry

public Environment copyEntry(int fromIndex,
                             int toIndex)
                      throws java.io.IOException,
                             ServiceException
Copies the specified property into a new position in the property list

Parameters:
fromIndex - the 0-based index to copy from
toIndex - the 0-based index to copy to, the new object will inserted at this index, moving existing objects down the list
Returns:
The Environment itself, for convenience
Throws:
java.io.IOException
ServiceException

clone

public Environment clone()
Clones this Environment, complete with related EnvironmentEntries (also cloned), but clears the environment group id of the cloned object making it ready for a .create() call.

Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getEnvGroupId

public int getEnvGroupId()
Returns the Environment Group Identifier


getLevel

public int getLevel()
Returns the security level associated with this Envionment

Returns:

getName

public java.lang.String getName()
Returns the pretty name of this Environment

Returns:

getEntries

public java.util.List<EnvironmentEntry> getEntries()
Returns the List of Entries currently associated with this Environment

Returns:

getEntry

public EnvironmentEntry getEntry(int index)
                          throws APIException
Retrieves an Entry by 0-based index

Parameters:
parameterName -
Returns:
Throws:
APIException

getEntry

public EnvironmentEntry getEntry(java.lang.String parameterName)
Retrieves an Entry by parameter name, or null if no Entry matches

Parameters:
parameterName -
Returns:

setLevel

public void setLevel(int level)
Sets the security level the will be associated with this Environment

Parameters:
level -

setName

public void setName(java.lang.String name)
Sets the pretty name of this Environment

Parameters:
name -