com.buildforge.services.client.dbo
Class Filter

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

public class Filter
extends java.lang.Object

An object representing a filter set within the Build Forge system. Filters sets contain a list of patterns that are matched against the log lines of step results. When a pattern matches, the engine will perform the action specified by the filter pattern.

This class defines the filter set itself. The actual filters that are applied are determined by the patterns that belong to the filter set.


Field Summary
static java.lang.Class<Filter> CLASS
           
 
Constructor Summary
Filter(APIClientConnection conn)
          Define a new filter set object.
 
Method Summary
 void addPattern(FilterPattern pattern)
          Adds a new pattern to this filter set at the end of the pattern list.
 void addPattern(FilterPattern pattern, int index)
          Adds a new pattern to this filter set at a specified index.
 Filter clone()
          Clones this Filter, complete with related FilterPatterns (also cloned), but clears the filter id of the cloned object making it ready for a .create() call.
 FilterPattern copyPattern(int fromIndex)
          Copies the specified property from a specified.
 Filter copyPattern(int fromIndex, int toIndex)
          Copies the specified property into a new position in the property list
 Filter create()
          Creates a new filter set, as defined by this object.
 void delete()
          Deletes this filter set and all of its patterns from the system.
static java.util.List<Filter> findAll(APIClientConnection conn)
          Finds all filter sets defined within the system to which the user has access.
static Filter findById(APIClientConnection conn, int filterId)
          Retrieves a filter set by its ID.
 int getFilterId()
          Returns the unique identifier for this Filter
 int getLevel()
          Returns the access level assigned to this Filter
 java.lang.String getName()
          Returns the pretty name for this Filter
 FilterPattern getPattern(int index)
          Returns the FilterPattern from the specified index
 java.util.List<FilterPattern> getPatterns()
          Returns a list of the related FilterPatterns for this Filter
 Filter movePattern(int fromIndex, int toIndex)
          Moves a pattern from one 0-based index to another.
 FilterPattern removePattern(FilterPattern pattern)
           
 FilterPattern removePattern(int index)
          Removes the FilterPattern at the specified, 0-based index from this Filter and the database if the Filter already exists in the database.
 void setLevel(int newLevel)
          Sets the access level assigned to this Filter
 void setName(java.lang.String name)
          Sets the pretty name of this Filter
 java.lang.String toString()
           
 Filter update()
          Updates this existing filter set to use the updated values in this object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS

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

Filter

public Filter(APIClientConnection conn)
Define a new filter set object. The filter set does not exist until after it has been created using the create() method.

Parameters:
conn - the services layer connection that the filter set object should use when submitting requests
Method Detail

findAll

public static java.util.List<Filter> findAll(APIClientConnection conn)
                                      throws java.io.IOException,
                                             ServiceException
Finds all filter sets defined within the system to which the user has access. A user has access to all filter sets for which the user has direct or indirect membership in the filter set's assigned access group. Filter sets are returned by this method without their member patterns. To retrieve the patterns for a filter set, use findById(APIClientConnection conn, int filterId).

Parameters:
conn - the connection to use for the request
Returns:
a list of filters
Throws:
java.io.IOException
ServiceException

findById

public static Filter findById(APIClientConnection conn,
                              int filterId)
                       throws java.io.IOException,
                              ServiceException
Retrieves a filter set by its ID.

Parameters:
conn - the connection to use for this request
filterId - the ID of the filter set to find
Returns:
the filter set, or null if the requested filter set could not be found.
Throws:
java.io.IOException
ServiceException

create

public Filter create()
              throws java.io.IOException,
                     ServiceException
Creates a new filter set, as defined by this object. If this filter set has any patterns attached, then they are created, as well.

Restrictions: Requires Permission.AddFilterSet.

Returns:
the newly created filter set
Throws:
java.io.IOException
ServiceException

update

public Filter update()
              throws java.io.IOException,
                     ServiceException
Updates this existing filter set to use the updated values in this object. Changes to its patterns are NOT committed by this method; call FilterPattern.update() on each of them, instead.

Restrictions: Requires Permission.AddFilterSet and direct or indirect membership in the access group that is assigned to the filter set.

Returns:
this filter set
Throws:
java.io.IOException
ServiceException

delete

public void delete()
            throws java.io.IOException,
                   ServiceException
Deletes this filter set and all of its patterns from the system.

Restrictions: Requires Permission.DeleteFilterSet and direct or indirect membership in the access group that is assigned to the filter set.

Throws:
java.io.IOException
ServiceException

addPattern

public void addPattern(FilterPattern pattern)
                throws ServiceException,
                       java.io.IOException
Adds a new pattern to this filter set at the end of the pattern list. If the filter set is already live, then this request is immediately sent to the server for approval.

Restrictions: Requires Permission.AddFilterSetEntry if the filter set object is already live.

Parameters:
pattern - the pattern to add to the filter set
Throws:
ServiceException
java.io.IOException

addPattern

public void addPattern(FilterPattern pattern,
                       int index)
                throws ServiceException,
                       java.io.IOException
Adds a new pattern to this filter set at a specified index. If the filter set is already live, then this request is immediately sent to the server for approval.

Restrictions: Requires Permission.AddFilterSetEntry if the filter set object is already live.

Parameters:
pattern - the pattern to add to the filter set
index - the 0-based index at which to insert the new pattern. If the specified value would place the new pattern at or beyond the end of the list, then it is placed at the end.
Throws:
ServiceException
java.io.IOException

removePattern

public FilterPattern removePattern(FilterPattern pattern)
                            throws ServiceException,
                                   java.io.IOException
Throws:
ServiceException
java.io.IOException

removePattern

public FilterPattern removePattern(int index)
                            throws ServiceException,
                                   java.io.IOException
Removes the FilterPattern at the specified, 0-based index from this Filter and the database if the Filter already exists in the database.

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

movePattern

public Filter movePattern(int fromIndex,
                          int toIndex)
                   throws java.io.IOException,
                          ServiceException
Moves a pattern from one 0-based index to another.

Parameters:
fromIndex -
toIndex -
Throws:
java.io.IOException
ServiceException

copyPattern

public FilterPattern copyPattern(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

copyPattern

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

Parameters:
fromIndex -
toIndex -
Returns:
The Environment itself, for convenience
Throws:
java.io.IOException
ServiceException

toString

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

clone

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

Overrides:
clone in class java.lang.Object

getFilterId

public int getFilterId()
Returns the unique identifier for this Filter


getName

public java.lang.String getName()
Returns the pretty name for this Filter


getLevel

public int getLevel()
Returns the access level assigned to this Filter


getPatterns

public java.util.List<FilterPattern> getPatterns()
Returns a list of the related FilterPatterns for this Filter


getPattern

public FilterPattern getPattern(int index)
                         throws APIException
Returns the FilterPattern from the specified index

Parameters:
index -
Returns:
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the supplied index is < 0 or >= the size of the list of patterns
APIException

setName

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

Parameters:
name -

setLevel

public void setLevel(int newLevel)
Sets the access level assigned to this Filter