com.buildforge.services.client.dbo
Class Selector

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

public class Selector
extends java.lang.Object

Selectors are used to test the data gathered by Collectors from agents running on Servers. These tests will determine whether or not a given Server is a fit and desirable platform for the execution of a particular Project. The property name of each child SelectorProperty will be used to locate values stored in the Server's manifest (the values stored will be defined by the Collector defined for that Server) and those values will be used as the left-hand side of the comparison. For example, if Server 'localhost' had a Collector associated with it that stored the 'NUM_CPU' built-in property (the number of CPUs on a Server), then that Server's manifest would be stored with the number of CPUs found on the physical box, say 2. If a Selector were defined with a SelectorProperty with a Property Name of 'NUM_CPU', an Operator of Operator.GE (Greater Than Or Equal To), and a value of 2, then Server 'localhost' would be found to be a suitable host to execute a Project associated with that Selector.

A full list of pre-defined, built-in properties that may be collected (such as NUM_CPU, MEM_FREE, etc.) can be obtained via #getBuiltIns().


Field Summary
static java.lang.Class<Selector> CLASS
           
 
Constructor Summary
Selector(APIClientConnection conn)
          Defines a new Selector object
 
Method Summary
 void addProperty(SelectorProperty prop)
          Adds a new SelectorProperty to this Selector.
 Selector clone()
          Clones this Selector, complete with related SelectorProperties (also cloned), but clears the selector id of the cloned object making it ready for a .create() call.
 Selector create()
          Creates this new Selector in the database
 void delete()
          Removes this Selector from the database
 boolean equals(java.lang.Object other)
           
static java.util.List<Selector> findAll(APIClientConnection conn)
          Returns the list of all Selectors in the system.
static Selector findById(APIClientConnection conn, java.lang.String selectorId)
          Retrives a Selector by name
 int getLevel()
          Returns the security access level required for permission to access this Selector
 java.util.Collection<SelectorProperty> getProperties()
          Returns a List with every SelectorProperty associated with this Selector
 java.lang.String getSelectorId()
          Returns the unique identifier for this Selector (its name).
 boolean removeProperty(SelectorProperty prop)
          Removes the provided SelectorProperty from both this parent object as well as the database
 void setLevel(int newLevel)
          Assigns a new access level that will required to access this object
 void setSelectorId(java.lang.String selectorId)
          Sets the unique identifier (name) of this Selector
 java.lang.String toString()
           
 Selector update()
          Commits the latest changes to this Selector to the database
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS

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

Selector

public Selector(APIClientConnection conn)
Defines a new Selector object

Parameters:
conn -
Method Detail

findAll

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

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

findById

public static Selector findById(APIClientConnection conn,
                                java.lang.String selectorId)
                         throws java.io.IOException,
                                ServiceException
Retrives a Selector by name

Parameters:
conn -
selectorId - The name of the Selector
Returns:
Throws:
java.io.IOException
ServiceException

create

public Selector create()
                throws java.io.IOException,
                       ServiceException
Creates this new Selector in the database

Returns:
Throws:
java.io.IOException
ServiceException

update

public Selector update()
                throws java.io.IOException,
                       ServiceException
Commits the latest changes to this Selector to the database

Returns:
Throws:
java.io.IOException
ServiceException

delete

public void delete()
            throws java.io.IOException,
                   ServiceException
Removes this Selector from the database

Throws:
java.io.IOException
ServiceException

addProperty

public void addProperty(SelectorProperty prop)
                 throws java.io.IOException,
                        ServiceException
Adds a new SelectorProperty to this Selector. If this Selector has already been .create()ed or obtained via a finder method, then the new SelectorProperty will immediately also be created in the database. Otherwise all SelectorProperties will be created in tandem with a call to .create() on this parent object.

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

removeProperty

public boolean removeProperty(SelectorProperty prop)
                       throws java.io.IOException,
                              ServiceException
Removes the provided SelectorProperty from both this parent object as well as the database

Parameters:
prop - The property to remove
Returns:
Throws:
java.io.IOException
ServiceException

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

clone

public Selector clone()
Clones this Selector, complete with related SelectorProperties (also cloned), but clears the selector id of the cloned object making it ready for a .create() call.

Overrides:
clone in class java.lang.Object

getSelectorId

public java.lang.String getSelectorId()
Returns the unique identifier for this Selector (its name).


getLevel

public int getLevel()
Returns the security access level required for permission to access this Selector


getProperties

public java.util.Collection<SelectorProperty> getProperties()
Returns a List with every SelectorProperty associated with this Selector


setSelectorId

public void setSelectorId(java.lang.String selectorId)
Sets the unique identifier (name) of this Selector

Parameters:
selectorId -

setLevel

public void setLevel(int newLevel)
Assigns a new access level that will required to access this object

Parameters:
newLevel -

toString

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