net.sf.jagzilla
Interface BugQuery

All Known Implementing Classes:
BugQueryHibernateImpl

public interface BugQuery

defines methods to query bugs. This class contains two different and important groups of methods:

The methods that modify bugs in database are:
Methods for addition

Methods for modification

Author:
mgriffa
See Also:
Bug, SystemQuery

Method Summary
 void addBug(Bug bug)
          adds a new bug to the database.
 void addBugAttach(Attachment attach)
          Adds an attachment to a bug.
 void addBugComment(int bugId, int userId, java.lang.String comment)
          adds a comment to the bug.
 void addBugWithComment(Bug bug, java.lang.String comment)
          adds a bug with comment as the first long description of the bug.
 void changeBugPriority(int profile, int bugId, java.lang.String pri, java.lang.String comment)
          changes the priority of a bug.
 void changeBugSeverity(int profile, int bugId, java.lang.String sev, java.lang.String comment)
          changes the severity of a bug.
 void changeBugStatus(int profile, int bugId, java.lang.String status, int asignee)
          changes the status of a bug.
 java.util.List getAllBugs()
          gets a list of all bugs in database.
 Bug getBugById(int id)
          gets the bug with the given id.
 int getBugCountForComponent(java.lang.String component)
          gets the total ammount of bugs for the given component.
 int getBugCountQuery(java.lang.String product, java.lang.String component, java.lang.String version, java.lang.String milestone, java.util.Date creationFrom, java.util.Date creationTo, java.lang.String priority, java.lang.String severity, java.lang.String status, java.lang.String resolution, int assignedTo)
          Deprecated. see getBugCountQuery(String, String, String , String , Date , Date , String , String , String , String , int , int )
 int getBugCountQuery(java.lang.String product, java.lang.String component, java.lang.String version, java.lang.String milestone, java.util.Date creationFrom, java.util.Date creationTo, java.lang.String priority, java.lang.String severity, java.lang.String status, java.lang.String resolution, int assignedTo, int reportedBy)
           
 int getBugCountWithStatus(java.lang.String status)
          return the ammount of bugs with given status.
 java.util.List getBugsAssignedTo(int userid)
          gets all bugs that are assigned to the specified user
 java.util.List getBugsForComponent(Component component)
          gets all bugs for the specified component
 java.util.List getBugsForMilestone(Milestone milestone)
          gets all bugs for the specified milestone
 java.util.List getBugsForProduct(Product product)
          gets all bugs for the specified product.
 java.util.List getBugsForVersion(Version version)
          gets all bugs for the specified version
 java.util.List getBugsQuery(java.lang.String product, java.lang.String component, java.lang.String version, java.lang.String milestone, java.util.Date creationFrom, java.util.Date creationTo, java.lang.String priority, java.lang.String severity, java.lang.String status, java.lang.String resolution, int assignedTo, int reportedBy)
          gets all bugs that match the criteria.
 java.util.List getBugsReportedBy(int userid)
          gets all bugs reported by the specified user.
 java.util.List getBugsSince(java.util.Date since)
          gets a list of bugs created after since
 java.util.List getCcList(int bugId)
          returns the cc list of a given bug.
 java.util.List getLastBugs(int count)
          gets the latest bugs.
 SystemQuery getSystemQuery()
          gets an instance of SystemQuery with configuration of current implementation.
 int getTotalBugCount()
          return the total ammount of bugs in database.
 void removeBug(int id)
          removes the bug with the given id
 void resolveBug(int profile, int bugId, java.lang.String resolution, int dupeId)
          resolves a bug.
 void updateBug(Bug bug)
          updates the bug.
 

Method Detail

getLastBugs

public java.util.List getLastBugs(int count)
                           throws JagzillaException
gets the latest bugs.

Parameters:
count - ammunt of bugs to be retrived.
Returns:
Throws:
JagzillaException
See Also:
Bug

getBugsAssignedTo

public java.util.List getBugsAssignedTo(int userid)
                                 throws JagzillaException,
                                        NoSuchProfileException
gets all bugs that are assigned to the specified user

Parameters:
userid - id of the user
Returns:
a List of bugs assigned to user id
Throws:
JagzillaException - if an error occurs
NoSuchProfileException - if the userid cannot be found
See Also:
Bug

getBugsReportedBy

public java.util.List getBugsReportedBy(int userid)
                                 throws JagzillaException,
                                        NoSuchProfileException
gets all bugs reported by the specified user.

Parameters:
userid - the user id
Returns:
a list of bugs reported by the user
Throws:
JagzillaException - if an error occurs
NoSuchProfileException - if the user cannot be found

getTotalBugCount

public int getTotalBugCount()
                     throws JagzillaException
return the total ammount of bugs in database.

Returns:
Throws:
JagzillaException

getBugById

public Bug getBugById(int id)
               throws JagzillaException,
                      NoSuchBugException
gets the bug with the given id.

Parameters:
id - the id of the bug to search for
Returns:
the Bug
Throws:
JagzillaException - if an error occurs
NoSuchBugException - if there is no bug with the given id
See Also:
Bug

getBugCountWithStatus

public int getBugCountWithStatus(java.lang.String status)
                          throws JagzillaException
return the ammount of bugs with given status. This method must be equivalent to getBugConuntQuery(null, status, null).

Parameters:
status - the status to search
Returns:
an integer counting the bugs found
Throws:
JagzillaException - if an error occurs

getBugCountForComponent

public int getBugCountForComponent(java.lang.String component)
                            throws JagzillaException
gets the total ammount of bugs for the given component.

Parameters:
component -
Returns:
Throws:
JagzillaException

getBugCountQuery

public int getBugCountQuery(java.lang.String product,
                            java.lang.String component,
                            java.lang.String version,
                            java.lang.String milestone,
                            java.util.Date creationFrom,
                            java.util.Date creationTo,
                            java.lang.String priority,
                            java.lang.String severity,
                            java.lang.String status,
                            java.lang.String resolution,
                            int assignedTo)
                     throws JagzillaException
Deprecated. see getBugCountQuery(String, String, String , String , Date , Date , String , String , String , String , int , int )

count bugs that match the specified criteria.

Parameters:
product -
component -
version -
milestone -
creationFrom - creation date from which to search bugs
creationTo - creation date to which to search bugs
priority -
severity -
status -
resolution -
assignedTo -
Returns:
Throws:
JagzillaException

getBugCountQuery

public int getBugCountQuery(java.lang.String product,
                            java.lang.String component,
                            java.lang.String version,
                            java.lang.String milestone,
                            java.util.Date creationFrom,
                            java.util.Date creationTo,
                            java.lang.String priority,
                            java.lang.String severity,
                            java.lang.String status,
                            java.lang.String resolution,
                            int assignedTo,
                            int reportedBy)
                     throws JagzillaException
Throws:
JagzillaException

getBugsQuery

public java.util.List getBugsQuery(java.lang.String product,
                                   java.lang.String component,
                                   java.lang.String version,
                                   java.lang.String milestone,
                                   java.util.Date creationFrom,
                                   java.util.Date creationTo,
                                   java.lang.String priority,
                                   java.lang.String severity,
                                   java.lang.String status,
                                   java.lang.String resolution,
                                   int assignedTo,
                                   int reportedBy)
                            throws JagzillaException,
                                   NoSuchProductException,
                                   NoSuchComponentException,
                                   NoSuchVersionException,
                                   NoSuchMilestoneException,
                                   NoSuchReporterException,
                                   NoSuchAsigneeException,
                                   BadStatusException,
                                   BadPriorityException,
                                   BadSeverityException,
                                   DateInFutureException
gets all bugs that match the criteria.

Parameters:
product -
component -
version -
milestone -
creationFrom -
creationTo -
priority -
severity -
status -
resolution -
assignedTo -
reportedBy -
Returns:
Throws:
JagzillaException
NoSuchProductException
NoSuchComponentException
NoSuchVersionException
NoSuchMilestoneException
NoSuchReporterException
NoSuchAsigneeException
BadStatusException
BadPriorityException
BadSeverityException
DateInFutureException

getBugsForProduct

public java.util.List getBugsForProduct(Product product)
                                 throws JagzillaException
gets all bugs for the specified product.

Parameters:
product -
Returns:
a list of Bugs
Throws:
JagzillaException - if an error occurs

getBugsForComponent

public java.util.List getBugsForComponent(Component component)
                                   throws JagzillaException
gets all bugs for the specified component

Parameters:
component -
Returns:
a list of Bugs
Throws:
JagzillaException - if an error occurs

getBugsForMilestone

public java.util.List getBugsForMilestone(Milestone milestone)
                                   throws JagzillaException
gets all bugs for the specified milestone

Parameters:
milestone -
Returns:
a list of bugs
Throws:
JagzillaException - if an error occurs

getBugsForVersion

public java.util.List getBugsForVersion(Version version)
                                 throws JagzillaException
gets all bugs for the specified version

Parameters:
version -
Returns:
a list of bugs
Throws:
JagzillaException - if an error occurs

getBugsSince

public java.util.List getBugsSince(java.util.Date since)
                            throws JagzillaException,
                                   DateInFutureException
gets a list of bugs created after since

Parameters:
since - Date of creation bugs
Returns:
a list of Bug opened after since date
Throws:
JagzillaException - if an error occurs
DateInFutureException - if the since parameter refences a future date

getAllBugs

public java.util.List getAllBugs()
                          throws JagzillaException
gets a list of all bugs in database. This method retrives all bugs in database whatever state they have, open, closed...

Returns:
a list of Bug
Throws:
JagzillaException - if an error occurs
See Also:
Bug

addBug

public void addBug(Bug bug)
            throws JagzillaException,
                   NoSuchProductException,
                   NoSuchComponentException,
                   NoSuchReporterException,
                   NoSuchAsigneeException,
                   NoSuchVersionException,
                   NoSuchMilestoneException,
                   ComponentNotUniqueException,
                   ProductComponentRelationException,
                   InconsistencyException
adds a new bug to the database. This class contains some logic for assigning default values to fields. This logic is like follows:
  1. if product is null and component is null not, product is assigned from component (see NotUniqueComponentException).
  2. if product is null and component is not null, product is resolved from the component.
  3. if product is not null and component is null, component is resolved from the product.
  4. if product is not null and component is not null, consistency is validated (component belongs to product).
  5. if assignTo is not specified the owner of the component is used.
  6. if milestone is not specified --- is used.
  7. if version is not specified a valid version is obtained for the product.

Parameters:
bug - the bug to add
Throws:
JagzillaException - if an error occurs
InconsistencyException - if there are no products in database or there are no components for specified product
NoSuchProductException - if the product specified is not null and cannot be found
NoSuchComponentException - if the component specified is not null and cannot be found
NoSuchReporterException - if the reporter specified is not null and cannot be found
NoSuchAsigneeException - if the asignee specified is not null and cannot be found
NoSuchVersionException - if the version specified is not null and cannot be found
NoSuchMilestoneException - if the milestone specified is not null and cannot be found
ComponentNotUniqueException - if the product is null, and the component name specified appears more than once
ProductComponentRelationException - if the component is not null and the product is not null and the component is not related to that product

addBugWithComment

public void addBugWithComment(Bug bug,
                              java.lang.String comment)
                       throws JagzillaException,
                              NoSuchProductException,
                              NoSuchComponentException
adds a bug with comment as the first long description of the bug. The userid of the comment is taken from the reporter. This methos is equivalent to call:
addBug(bug); addBugComment(bug.getId(), bug.getReporter(), comment);

Parameters:
bug -
comment -
Throws:
JagzillaException
NoSuchProductException
NoSuchComponentException

addBugComment

public void addBugComment(int bugId,
                          int userId,
                          java.lang.String comment)
                   throws JagzillaException,
                          NoSuchBugException,
                          NoSuchProfileException
adds a comment to the bug.

Parameters:
bugId - the bug id to which the comment will be added.
userId - id of the profile requesting the operation
comment - comment to add
Throws:
JagzillaException - if an error occurs
NoSuchBugException - if the bugId did not retrive an existent bug
NoSuchProfileException - if the profileId cannot be found

addBugAttach

public void addBugAttach(Attachment attach)
                  throws JagzillaException,
                         NoSuchBugException,
                         NoSuchProfileException
Adds an attachment to a bug. The bug id and submitter id are taken from the Attachment getBugId and getSubmitterId methods.

Parameters:
attach - the attachment to add
Throws:
JagzillaException - if an error occurs
NoSuchBugException - if the bugId did not retrive an existent bug
NoSuchProfileException - if the userId did not retrive an existent profile
See Also:
Attachment

removeBug

public void removeBug(int id)
               throws JagzillaException,
                      NoSuchBugException
removes the bug with the given id

Parameters:
id - if of the bug to remove
Throws:
JagzillaException - if an error occurs
NoSuchBugException - if the bug cannot be found

updateBug

public void updateBug(Bug bug)
               throws JagzillaException,
                      NoSuchProductException,
                      NoSuchComponentException,
                      NoSuchReporterException,
                      NoSuchAsigneeException,
                      NoSuchVersionException,
                      NoSuchMilestoneException
updates the bug.

Parameters:
bug - bug with new data
Throws:
JagzillaException - if an error occurs
NoSuchProductException - if the product specified is not null and cannot be found
NoSuchComponentException - if the component specified is not null and cannot be found
NoSuchReporterException - if the reporter specified is not null and cannot be found
NoSuchAsigneeException - if the asignee specified is not null and cannot be found
NoSuchVersionException - if the version specified is not null and cannot be found
NoSuchMilestoneException - if the milestone specified is not null and cannot be found

changeBugStatus

public void changeBugStatus(int profile,
                            int bugId,
                            java.lang.String status,
                            int asignee)
                     throws JagzillaException,
                            NoSuchBugException,
                            NoSuchProfileException
changes the status of a bug. NOTE: When the status to change is Bug.STATUS_RESOLVED the application should also call resolveBug in order to specify the resolution the bug is assigned.

Parameters:
profile - id of the user requesting the action
bugId - id of the bug to change
asignee - id of the user the bug is assigned to only if the status is ASSIGNED, this value is ignored in other statuses.
status - new value for the status fiedl, must be in Bug.STATUS_ARR
Throws:
JagzillaException - if an error occurs
NoSuchBugException - if the bug cannot be found
NoSuchProfileException - if the profile cannot be found or status is assigned and the asignee profile cannot be found
BadStatusException - if the status is not a constant value in the Bug class
See Also:
resolveBug(int, int, String, int)

changeBugPriority

public void changeBugPriority(int profile,
                              int bugId,
                              java.lang.String pri,
                              java.lang.String comment)
                       throws JagzillaException,
                              NoSuchBugException,
                              NoSuchProfileException,
                              BadPriorityException
changes the priority of a bug.

Parameters:
profile - id of user requesting the operation
bugId - if of bug to change priority
pri - new priority. must be defined in Bug
comment - optional comment to add. can be null
Throws:
JagzillaException - if an error occurs
NoSuchBugException - if the bug with given id cannot be found
NoSuchProfileException - if the profile with given id cannot be found
BadPriorityException - if priority is not a Bug constant
See Also:
Bug

changeBugSeverity

public void changeBugSeverity(int profile,
                              int bugId,
                              java.lang.String sev,
                              java.lang.String comment)
                       throws JagzillaException,
                              NoSuchBugException,
                              NoSuchProfileException,
                              BadSeverityException
changes the severity of a bug.

Parameters:
profile - id of user requesting the operation
bugId - if of bug to change priority
sev - new severity. must be defined in Bug
comment - optional comment to add. can be null
Throws:
JagzillaException - if an error occurs
NoSuchBugException - if the bug with given id cannot be found
NoSuchProfileException - if the profile with given id cannot be found
BadSeverityException - if severity is not a Bug constant
See Also:
Bug

resolveBug

public void resolveBug(int profile,
                       int bugId,
                       java.lang.String resolution,
                       int dupeId)
                throws JagzillaException,
                       NoSuchBugException,
                       BadResolutionException
resolves a bug. Before calling this method applications should call changeBugStatus. If the bug is not in Bug.STATUS_RESOLVED this method will invoke changeBugStatus to make the bug status resolved. Notice however, that this will not work in all cases, since when a bug is initially resolved it can be changed the resolution many times and the record of resolution change will not be added since bug.getStatus() will report Bug.STATUS_RESOLVED.

Parameters:
profile - id of the user requesting the action
bugId - id of the bug to change
resolution - resolution to set. must be a constant value in Bug
dupeId - if of duplicate-of bug. This field is only meaningfull is resolutions is RESOLUTION_DUPLICATE. It's value is ignored on other cases.
Throws:
JagzillaException - if an error occurs
NoSuchBugException - if the bug cannot be found, or if resolution is duplicate and dupeId cannot be found
BadResolutionException - if the resolution is not a constant of the Bug class
See Also:
changeBugStatus(int, int, String, int)

getCcList

public java.util.List getCcList(int bugId)
                         throws JagzillaException,
                                NoSuchBugException
returns the cc list of a given bug.

Parameters:
bugId - the id of the bug to search the cc list for.
Returns:
a List of Profile
Throws:
JagzillaException - if an error occurs
InconsistencyException - if a profile is not found in profiles tables with the id given in cc table
NoSuchBugException - if the bug id cannot be found
See Also:
Profile, SystemQuery.addCc(int,int), SystemQuery.removeCc(int,int)

getSystemQuery

public SystemQuery getSystemQuery()
                           throws JagzillaException
gets an instance of SystemQuery with configuration of current implementation.

Returns:
an instance of SystemQuery
Throws:
JagzillaException - if an error occurs


Distributed under the GPL. By Miguel Griffa. See the Jagzilla project page for more info.