net.sf.jagzilla
Class BugQueryHibernateImpl

java.lang.Object
  extended bynet.sf.jagzilla.BaseQuery
      extended bynet.sf.jagzilla.BugQueryHibernateImpl
All Implemented Interfaces:
BugQuery

public class BugQueryHibernateImpl
extends BaseQuery
implements BugQuery

implements service interface with hibernate to acces database.

Author:
mike

Field Summary
 
Fields inherited from class net.sf.jagzilla.BaseQuery
eventHandler, hibernateProperties, session, sessionFactory
 
Constructor Summary
BugQueryHibernateImpl()
          constructs an hibernate implementation with default hibernate properties.
BugQueryHibernateImpl(java.util.Properties p)
          constructs an imeplementation with the hibernate properties received.
See the other constructor to see hibernate properties used.
 
Method Summary
 void addBug(Bug bug)
          adds a new bug to the database.
 void addBugAttach(Attachment attachment)
          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.
 void finalize()
           
 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)
          count bugs that match the specified criteria.
 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)
           
 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.Properties getHibernateProperties()
           
 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(Bug bug)
           
 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.
 
Methods inherited from class net.sf.jagzilla.BaseQuery
bugExists, componentExists, continueIfProductExists, continueIfResolutionExists, continueIfStatusExists, continueIfUsersExists, getEventHandler, getFieldId, getNewSession, locateBug, locateComponent, locateProduct, locateProfile, milestoneExists, priorityExists, productExists, queryCountValue, resolutionExists, setHibernateProperties, severityExists, statusExists, userExists, versionExists
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BugQueryHibernateImpl

public BugQueryHibernateImpl()
                      throws HibernateException,
                             BadParameterException,
                             java.io.IOException
constructs an hibernate implementation with default hibernate properties. hibernate properties used are:

Throws:
HibernateException
BadParameterException
java.io.IOException - if the event handler cfg file is not found

BugQueryHibernateImpl

public BugQueryHibernateImpl(java.util.Properties p)
                      throws HibernateException,
                             BadParameterException,
                             java.io.IOException
constructs an imeplementation with the hibernate properties received.
See the other constructor to see hibernate properties used.

Parameters:
p - hibernate properties to use
Throws:
HibernateException
BadParameterException
java.io.IOException
See Also:
BugQueryHibernateImpl()
Method Detail

getLastBugs

public java.util.List getLastBugs(int count)
                           throws JagzillaException
Description copied from interface: BugQuery
gets the latest bugs.

Specified by:
getLastBugs in interface BugQuery
Parameters:
count - ammunt of bugs to be retrived.
Returns:
Throws:
JagzillaException
See Also:
Bug

getBugsAssignedTo

public java.util.List getBugsAssignedTo(int userid)
                                 throws JagzillaException
Description copied from interface: BugQuery
gets all bugs that are assigned to the specified user

Specified by:
getBugsAssignedTo in interface BugQuery
Parameters:
userid - id of the user
Returns:
a List of bugs assigned to user id
Throws:
JagzillaException - if an error occurs
See Also:
Bug

getTotalBugCount

public int getTotalBugCount()
                     throws JagzillaException
Description copied from interface: BugQuery
return the total ammount of bugs in database.

Specified by:
getTotalBugCount in interface BugQuery
Returns:
Throws:
JagzillaException

getBugCountWithStatus

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

Specified by:
getBugCountWithStatus in interface BugQuery
Parameters:
status - the status to search
Returns:
an integer counting the bugs found
Throws:
JagzillaException - if an error occurs

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)
                            throws JagzillaException
Throws:
JagzillaException

finalize

public void finalize()

getHibernateProperties

public java.util.Properties getHibernateProperties()
Returns:
Returns the hibernateProperties.

addBug

public void addBug(Bug bug)
            throws JagzillaException,
                   NoSuchProductException,
                   NoSuchComponentException,
                   NoSuchReporterException,
                   NoSuchAsigneeException,
                   ComponentNotUniqueException,
                   ProductComponentRelationException
Description copied from interface: BugQuery
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.

Specified by:
addBug in interface BugQuery
Parameters:
bug - the bug to add
Throws:
ComponentNotUniqueException - if the product is null, and the component name specified appears more than once
NoSuchAsigneeException - if the asignee specified is not null and cannot be found
JagzillaException - if an error occurs
NoSuchComponentException - if the component specified is not null and cannot be found
NoSuchReporterException - if the reporter specified is not null and cannot be found
NoSuchProductException - if the product specified is not null and cannot be found
ProductComponentRelationException - if the component is not null and the product is not null and the component is not related to that product

removeBug

public void removeBug(Bug bug)
               throws JagzillaException,
                      NoSuchBugException
Throws:
JagzillaException
NoSuchBugException

removeBug

public void removeBug(int id)
               throws JagzillaException,
                      NoSuchBugException
Description copied from interface: BugQuery
removes the bug with the given id

Specified by:
removeBug in interface BugQuery
Parameters:
id - if of the bug to remove
Throws:
NoSuchBugException - if the bug cannot be found
JagzillaException - if an error occurs

getBugCountForComponent

public int getBugCountForComponent(java.lang.String component)
                            throws JagzillaException
Description copied from interface: BugQuery
gets the total ammount of bugs for the given component.

Specified by:
getBugCountForComponent in interface BugQuery
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
Description copied from interface: BugQuery
count bugs that match the specified criteria.

Specified by:
getBugCountQuery in interface BugQuery
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

addBugComment

public void addBugComment(int bugId,
                          int userId,
                          java.lang.String comment)
                   throws JagzillaException,
                          NoSuchProfileException,
                          NoSuchBugException
Description copied from interface: BugQuery
adds a comment to the bug.

Specified by:
addBugComment in interface BugQuery
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:
NoSuchProfileException - if the profileId cannot be found
JagzillaException - if an error occurs
NoSuchBugException - if the bugId did not retrive an existent bug

addBugAttach

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

Specified by:
addBugAttach in interface BugQuery
Parameters:
attachment - the attachment to add
Throws:
NoSuchProfileException - if the userId did not retrive an existent profile
NoSuchBugException - if the bugId did not retrive an existent bug
JagzillaException - if an error occurs
See Also:
Attachment

getBugById

public Bug getBugById(int id)
               throws JagzillaException,
                      NoSuchBugException
Description copied from interface: BugQuery
gets the bug with the given id.

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

getBugsSince

public java.util.List getBugsSince(java.util.Date since)
                            throws JagzillaException,
                                   DateInFutureException
Description copied from interface: BugQuery
gets a list of bugs created after since

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

getBugsForProduct

public java.util.List getBugsForProduct(Product product)
                                 throws JagzillaException
Description copied from interface: BugQuery
gets all bugs for the specified product.

Specified by:
getBugsForProduct in interface BugQuery
Parameters:
product -
Returns:
a list of Bugs
Throws:
JagzillaException - if an error occurs

getBugsForComponent

public java.util.List getBugsForComponent(Component component)
                                   throws JagzillaException
Description copied from interface: BugQuery
gets all bugs for the specified component

Specified by:
getBugsForComponent in interface BugQuery
Parameters:
component -
Returns:
a list of Bugs
Throws:
JagzillaException - if an error occurs

getBugsForMilestone

public java.util.List getBugsForMilestone(Milestone milestone)
                                   throws JagzillaException
Description copied from interface: BugQuery
gets all bugs for the specified milestone

Specified by:
getBugsForMilestone in interface BugQuery
Parameters:
milestone -
Returns:
a list of bugs
Throws:
JagzillaException - if an error occurs

getBugsForVersion

public java.util.List getBugsForVersion(Version version)
                                 throws JagzillaException
Description copied from interface: BugQuery
gets all bugs for the specified version

Specified by:
getBugsForVersion in interface BugQuery
Parameters:
version -
Returns:
a list of bugs
Throws:
JagzillaException - if an error occurs

addBugWithComment

public void addBugWithComment(Bug bug,
                              java.lang.String comment)
                       throws JagzillaException,
                              NoSuchProductException,
                              NoSuchComponentException
Description copied from interface: BugQuery
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);

Specified by:
addBugWithComment in interface BugQuery
Parameters:
bug -
comment -
Throws:
JagzillaException
NoSuchComponentException
NoSuchProductException

changeBugStatus

public void changeBugStatus(int profile,
                            int bugId,
                            java.lang.String status,
                            int asignee)
                     throws JagzillaException,
                            NoSuchBugException,
                            BadStatusException
Description copied from interface: BugQuery
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.

Specified by:
changeBugStatus in interface BugQuery
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:
NoSuchBugException - if the bug cannot be found
JagzillaException - if an error occurs
BadStatusException - if the status is not a constant value in the Bug class
See Also:
BugQuery.resolveBug(int, int, String, int)

resolveBug

public void resolveBug(int profile,
                       int bugId,
                       java.lang.String resolution,
                       int dupeId)
                throws JagzillaException,
                       NoSuchBugException,
                       BadResolutionException
Description copied from interface: BugQuery
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.

Specified by:
resolveBug in interface BugQuery
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
BadResolutionException - if the resolution is not a constant of the Bug class
NoSuchBugException - if the bug cannot be found, or if resolution is duplicate and dupeId cannot be found
See Also:
BugQuery.changeBugStatus(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
Description copied from interface: BugQuery
changes the priority of a bug.

Specified by:
changeBugPriority in interface BugQuery
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:
BadPriorityException - if priority is not a Bug constant
NoSuchProfileException - if the profile with given id cannot be found
JagzillaException - if an error occurs
NoSuchBugException - if the bug with given id cannot be found
See Also:
Bug

changeBugSeverity

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

Specified by:
changeBugSeverity in interface BugQuery
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:
NoSuchProfileException - if the profile with given id cannot be found
JagzillaException - if an error occurs
NoSuchBugException - if the bug with given id cannot be found
BadSeverityException - if severity is not a Bug constant
See Also:
Bug

getBugsReportedBy

public java.util.List getBugsReportedBy(int userid)
                                 throws JagzillaException,
                                        NoSuchProfileException
Description copied from interface: BugQuery
gets all bugs reported by the specified user.

Specified by:
getBugsReportedBy in interface BugQuery
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

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
Description copied from interface: BugQuery
gets all bugs that match the criteria.

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

updateBug

public void updateBug(Bug bug)
               throws JagzillaException,
                      NoSuchProductException,
                      NoSuchComponentException,
                      NoSuchReporterException,
                      NoSuchAsigneeException,
                      NoSuchVersionException,
                      NoSuchMilestoneException
Description copied from interface: BugQuery
updates the bug.

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

getAllBugs

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

Specified by:
getAllBugs in interface BugQuery
Returns:
a list of Bug
Throws:
JagzillaException - if an error occurs
See Also:
Bug

getCcList

public java.util.List getCcList(int bugId)
                         throws JagzillaException,
                                NoSuchBugException
Description copied from interface: BugQuery
returns the cc list of a given bug.

Specified by:
getCcList in interface BugQuery
Parameters:
bugId - the id of the bug to search the cc list for.
Returns:
a List of Profile
Throws:
NoSuchBugException - if the bug id cannot be found
JagzillaException - if an error occurs
See Also:
Profile, SystemQuery.addCc(int,int), SystemQuery.removeCc(int,int)

getSystemQuery

public SystemQuery getSystemQuery()
                           throws JagzillaException
Description copied from interface: BugQuery
gets an instance of SystemQuery with configuration of current implementation.

Specified by:
getSystemQuery in interface BugQuery
Returns:
an instance of SystemQuery
Throws:
JagzillaException - if an error occurs

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
Specified by:
getBugCountQuery in interface BugQuery
Throws:
JagzillaException


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