org.itracker.services.implementations
Class IssueServiceImpl

java.lang.Object
  extended by org.itracker.services.implementations.IssueServiceImpl
All Implemented Interfaces:
IssueService

public class IssueServiceImpl
extends Object
implements IssueService

Issue related service layer. A bit "fat" at this time, because of being a direct EJB porting. Going go get thinner over time

Author:
ricardo

Constructor Summary
IssueServiceImpl(UserDAO userDAO, ProjectDAO projectDAO, IssueDAO issueDAO, IssueHistoryDAO issueHistoryDAO, IssueRelationDAO issueRelationDAO, IssueAttachmentDAO issueAttachmentDAO, ComponentDAO componentDAO, IssueActivityDAO issueActivityDAO, VersionDAO versionDAO, CustomFieldDAO customFieldDAO, NotificationService notificationService)
           
 
Method Summary
 boolean addIssueAttachment(IssueAttachment attachment, byte[] data)
          Adds an attachment to an issue
 boolean addIssueHistory(IssueHistory history)
          this should not exist.
 boolean addIssueRelation(Integer issueId, Integer relatedIssueId, int relationType, Integer userId)
          add a relation between two issues.
 boolean assignIssue(Integer issueId, Integer userId)
           
 boolean assignIssue(Integer issueId, Integer userId, Integer assignedByUserId)
          only use for updating issue from actions..
 boolean canViewIssue(Integer issueId, User user)
           
 boolean canViewIssue(Issue issue, User user)
           
 Issue createIssue(Issue issue, Integer projectId, Integer userId, Integer createdById)
          Creates a new issue in a project.
 Long getAllIssueAttachmentCount()
           
 List<IssueAttachment> getAllIssueAttachments()
          Deprecated. do not use this due to expensive memory use! use explicit hsqldb queries instead.
 Long getAllIssueAttachmentSize()
          get total size of all attachments in database
 List<Issue> getAllIssues()
          Deprecated. don't use to expensive memory use!
 Issue getIssue(Integer issueId)
           
 List<IssueActivity> getIssueActivity(Integer issueId)
           
 List<IssueActivity> getIssueActivity(Integer issueId, boolean notificationSent)
          TODO move to NotificationService ?
 IssueAttachment getIssueAttachment(Integer attachmentId)
           
 int getIssueAttachmentCount(Integer issueId)
           
 byte[] getIssueAttachmentData(Integer attachmentId)
          Returns the binary data for an attachment.
 List<IssueAttachment> getIssueAttachments(Integer issueId)
           
 HashSet<Integer> getIssueComponentIds(Integer issueId)
           
 List<Component> getIssueComponents(Integer issueId)
           
 User getIssueCreator(Integer issueId)
           
 List<IssueHistory> getIssueHistory(Integer issueId)
          Old implementation is left here, commented, because it checked for history entry status.
 User getIssueOwner(Integer issueId)
           
 Project getIssueProject(Integer issueId)
           
 IssueRelation getIssueRelation(Integer relationId)
           
 List<Issue> getIssuesByProjectId(Integer projectId)
           
 List<Issue> getIssuesByProjectId(Integer projectId, int status)
           
 List<Issue> getIssuesCreatedByUser(Integer userId)
           
 List<Issue> getIssuesCreatedByUser(Integer userId, boolean availableProjectsOnly)
           
 List<Issue> getIssuesOwnedByUser(Integer userId)
           
 List<Issue> getIssuesOwnedByUser(Integer userId, boolean availableProjectsOnly)
           
 List<Issue> getIssuesWatchedByUser(Integer userId)
           
 List<Issue> getIssuesWatchedByUser(Integer userId, boolean availableProjectsOnly)
          TODO move to NotificationService
 List<Issue> getIssuesWithSeverity(int severity)
          Returns all issues with a severity equal to the given severity number
 List<Issue> getIssuesWithStatus(int status)
          Returns all issues with a status equal to the given status number
 List<Issue> getIssuesWithStatusLessThan(int status)
          Returns all issues with a status less than the given status number
 HashSet<Integer> getIssueVersionIds(Integer issueId)
           
 List<Version> getIssueVersions(Integer issueId)
           
 IssueHistory getLastIssueHistory(Integer issueId)
          Returns the latest issue history entry for a particular issue.
 Date getLatestIssueDateByProjectId(Integer projectId)
           
 Long getNumberIssues()
          Added implementation to make proper count of ALL issues, instead select them in a list and return its size
 int getOpenIssueCountByProjectId(Integer projectId)
           
 int getResolvedIssueCountByProjectId(Integer projectId)
           
 int getTotalIssueCountByProjectId(Integer projectId)
           
 List<Issue> getUnassignedIssues()
           
 List<Issue> getUnassignedIssues(boolean availableProjectsOnly)
           
 Issue moveIssue(Issue issue, Integer projectId, Integer userId)
          Moves an issues from its current project to a new project.
 boolean removeIssueAttachment(Integer attachmentId)
          Removes a attachement (deletes it)
 Integer removeIssueHistoryEntry(Integer entryId, Integer userId)
           
 void removeIssueRelation(Integer relationId, Integer userId)
           
 List<Issue> searchIssues(IssueSearchQuery queryModel, User user, Map<Integer,Set<PermissionType>> userPermissions)
           
 boolean setIssueAttachmentData(Integer attachmentId, byte[] data)
          Updates the binary data of the attachment stored in the database.
 boolean setIssueAttachmentData(String fileName, byte[] data)
          Updates the binary data of the attachment stored in the database.
 boolean setIssueComponents(Integer issueId, HashSet<Integer> componentIds, Integer userId)
           
 boolean setIssueFields(Integer issueId, List<IssueField> fields)
          TODO maybe it has no use at all.
 boolean setIssueVersions(Integer issueId, HashSet<Integer> versionIds, Integer userId)
           
 Issue systemUpdateIssue(Issue updateissue, Integer userId)
          System-Update an issue, adds the action to the issue and updates the issue
 Long totalSystemIssuesAttachmentSize()
           
 Issue updateIssue(Issue issueDirty, Integer userId)
          Save a modified issue to the persistence layer
 void updateIssueActivityNotification(Integer issueId, boolean notificationSent)
          I think this entire method is useless - RJST TODO move to NotificationService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IssueServiceImpl

public IssueServiceImpl(UserDAO userDAO,
                        ProjectDAO projectDAO,
                        IssueDAO issueDAO,
                        IssueHistoryDAO issueHistoryDAO,
                        IssueRelationDAO issueRelationDAO,
                        IssueAttachmentDAO issueAttachmentDAO,
                        ComponentDAO componentDAO,
                        IssueActivityDAO issueActivityDAO,
                        VersionDAO versionDAO,
                        CustomFieldDAO customFieldDAO,
                        NotificationService notificationService)
Method Detail

getIssue

public Issue getIssue(Integer issueId)
Specified by:
getIssue in interface IssueService

getAllIssues

public List<Issue> getAllIssues()
Deprecated. don't use to expensive memory use!

Specified by:
getAllIssues in interface IssueService
Returns:

getNumberIssues

public Long getNumberIssues()
Added implementation to make proper count of ALL issues, instead select them in a list and return its size

Specified by:
getNumberIssues in interface IssueService

getIssuesCreatedByUser

public List<Issue> getIssuesCreatedByUser(Integer userId)
Specified by:
getIssuesCreatedByUser in interface IssueService

getIssuesCreatedByUser

public List<Issue> getIssuesCreatedByUser(Integer userId,
                                          boolean availableProjectsOnly)
Specified by:
getIssuesCreatedByUser in interface IssueService

getIssuesOwnedByUser

public List<Issue> getIssuesOwnedByUser(Integer userId)
Specified by:
getIssuesOwnedByUser in interface IssueService

getIssuesOwnedByUser

public List<Issue> getIssuesOwnedByUser(Integer userId,
                                        boolean availableProjectsOnly)
Specified by:
getIssuesOwnedByUser in interface IssueService

getIssuesWatchedByUser

public List<Issue> getIssuesWatchedByUser(Integer userId)
Specified by:
getIssuesWatchedByUser in interface IssueService

getIssuesWatchedByUser

public List<Issue> getIssuesWatchedByUser(Integer userId,
                                          boolean availableProjectsOnly)
TODO move to NotificationService

Specified by:
getIssuesWatchedByUser in interface IssueService

getUnassignedIssues

public List<Issue> getUnassignedIssues()
Specified by:
getUnassignedIssues in interface IssueService

getUnassignedIssues

public List<Issue> getUnassignedIssues(boolean availableProjectsOnly)
Specified by:
getUnassignedIssues in interface IssueService

getIssuesWithStatus

public List<Issue> getIssuesWithStatus(int status)
Returns all issues with a status equal to the given status number

Specified by:
getIssuesWithStatus in interface IssueService
Parameters:
status - the status to compare
Returns:
an array of IssueModels that match the criteria

getIssuesWithStatusLessThan

public List<Issue> getIssuesWithStatusLessThan(int status)
Returns all issues with a status less than the given status number

Specified by:
getIssuesWithStatusLessThan in interface IssueService
Parameters:
status - the status to compare
Returns:
an array of IssueModels that match the criteria

getIssuesWithSeverity

public List<Issue> getIssuesWithSeverity(int severity)
Returns all issues with a severity equal to the given severity number

Specified by:
getIssuesWithSeverity in interface IssueService
Parameters:
severity - the severity to compare
Returns:
an array of IssueModels that match the criteria

getIssuesByProjectId

public List<Issue> getIssuesByProjectId(Integer projectId)
Specified by:
getIssuesByProjectId in interface IssueService

getIssuesByProjectId

public List<Issue> getIssuesByProjectId(Integer projectId,
                                        int status)
Specified by:
getIssuesByProjectId in interface IssueService

getIssueCreator

public User getIssueCreator(Integer issueId)
Specified by:
getIssueCreator in interface IssueService

getIssueOwner

public User getIssueOwner(Integer issueId)
Specified by:
getIssueOwner in interface IssueService

getIssueComponents

public List<Component> getIssueComponents(Integer issueId)
Specified by:
getIssueComponents in interface IssueService

getIssueVersions

public List<Version> getIssueVersions(Integer issueId)
Specified by:
getIssueVersions in interface IssueService

getIssueAttachments

public List<IssueAttachment> getIssueAttachments(Integer issueId)
Specified by:
getIssueAttachments in interface IssueService

getIssueHistory

public List<IssueHistory> getIssueHistory(Integer issueId)
Old implementation is left here, commented, because it checked for history entry status. This feature was not finished, I think (RJST)

Specified by:
getIssueHistory in interface IssueService

createIssue

public Issue createIssue(Issue issue,
                         Integer projectId,
                         Integer userId,
                         Integer createdById)
                  throws ProjectException
Description copied from interface: IssueService
Creates a new issue in a project.

Specified by:
createIssue in interface IssueService
projectId - the projectId the issue belongs to
userId - the id of registered creator of the new issue
createdById - the id of the actual creator of the issue. This would normally be the same as the userId.
Returns:
an Issue containing the newly created issue, or null if the create failed
Throws:
ProjectException

updateIssue

public Issue updateIssue(Issue issueDirty,
                         Integer userId)
                  throws ProjectException
Save a modified issue to the persistence layer

Specified by:
updateIssue in interface IssueService
Parameters:
issueDirty - the changed, unsaved issue to update on persistency layer
userId - the user-id of the changer
Throws:
ProjectException

moveIssue

public Issue moveIssue(Issue issue,
                       Integer projectId,
                       Integer userId)
Moves an issues from its current project to a new project.

Specified by:
moveIssue in interface IssueService
Parameters:
issue - an Issue of the issue to move
projectId - the id of the target project
userId - the id of the user that is moving the issue
Returns:
an Issue of the issue after it has been moved

addIssueHistory

public boolean addIssueHistory(IssueHistory history)
this should not exist. adding an history entry should be adding the history entry to the domain object and saving the object...

Specified by:
addIssueHistory in interface IssueService

setIssueFields

public boolean setIssueFields(Integer issueId,
                              List<IssueField> fields)
TODO maybe it has no use at all. is it obsolete? when I'd set the issue-fields on an issue and then save/update issue, would it be good enough?

Specified by:
setIssueFields in interface IssueService
Returns:

setIssueComponents

public boolean setIssueComponents(Integer issueId,
                                  HashSet<Integer> componentIds,
                                  Integer userId)
Specified by:
setIssueComponents in interface IssueService

setIssueVersions

public boolean setIssueVersions(Integer issueId,
                                HashSet<Integer> versionIds,
                                Integer userId)
Specified by:
setIssueVersions in interface IssueService

getIssueRelation

public IssueRelation getIssueRelation(Integer relationId)
Specified by:
getIssueRelation in interface IssueService

addIssueRelation

public boolean addIssueRelation(Integer issueId,
                                Integer relatedIssueId,
                                int relationType,
                                Integer userId)
add a relation between two issues. TODO: There is no relation saved to database yet?

Specified by:
addIssueRelation in interface IssueService

removeIssueRelation

public void removeIssueRelation(Integer relationId,
                                Integer userId)
Specified by:
removeIssueRelation in interface IssueService

assignIssue

public boolean assignIssue(Integer issueId,
                           Integer userId)
Specified by:
assignIssue in interface IssueService
Returns:

assignIssue

public boolean assignIssue(Integer issueId,
                           Integer userId,
                           Integer assignedByUserId)
only use for updating issue from actions..

Specified by:
assignIssue in interface IssueService
Returns:

systemUpdateIssue

public Issue systemUpdateIssue(Issue updateissue,
                               Integer userId)
                        throws ProjectException
System-Update an issue, adds the action to the issue and updates the issue

Specified by:
systemUpdateIssue in interface IssueService
Throws:
ProjectException

updateIssueActivityNotification

public void updateIssueActivityNotification(Integer issueId,
                                            boolean notificationSent)
I think this entire method is useless - RJST TODO move to NotificationService

Parameters:
model -
issue -
user -

addIssueAttachment

public boolean addIssueAttachment(IssueAttachment attachment,
                                  byte[] data)
Adds an attachment to an issue

Specified by:
addIssueAttachment in interface IssueService
Parameters:
model - The attachment data
data - The byte data

setIssueAttachmentData

public boolean setIssueAttachmentData(Integer attachmentId,
                                      byte[] data)
Description copied from interface: IssueService
Updates the binary data of the attachment stored in the database.

Specified by:
setIssueAttachmentData in interface IssueService
Parameters:
attachmentId - the id of the attachment to update
data - a byte arrray of the binary data for the attachment
Returns:
true if the update was successful

setIssueAttachmentData

public boolean setIssueAttachmentData(String fileName,
                                      byte[] data)
Description copied from interface: IssueService
Updates the binary data of the attachment stored in the database. Used mainly to take an existing attachment stored on the filesystem and move it into the database.

Specified by:
setIssueAttachmentData in interface IssueService
Parameters:
fileName - the filename listed in the database for the localtion of the attachment. This is the name that was previously used to store the data on the filesystem, not the original filename of the attachment.
data - a byte arrray of the binary data for the attachment
Returns:
true if the update was successful

removeIssueAttachment

public boolean removeIssueAttachment(Integer attachmentId)
Removes a attachement (deletes it)

Specified by:
removeIssueAttachment in interface IssueService
Parameters:
attachmentId - the id of the IssueAttachmentBean

removeIssueHistoryEntry

public Integer removeIssueHistoryEntry(Integer entryId,
                                       Integer userId)
Specified by:
removeIssueHistoryEntry in interface IssueService

getIssueProject

public Project getIssueProject(Integer issueId)
Specified by:
getIssueProject in interface IssueService

getIssueComponentIds

public HashSet<Integer> getIssueComponentIds(Integer issueId)
Specified by:
getIssueComponentIds in interface IssueService

getIssueVersionIds

public HashSet<Integer> getIssueVersionIds(Integer issueId)
Specified by:
getIssueVersionIds in interface IssueService

getIssueActivity

public List<IssueActivity> getIssueActivity(Integer issueId)
Specified by:
getIssueActivity in interface IssueService

getIssueActivity

public List<IssueActivity> getIssueActivity(Integer issueId,
                                            boolean notificationSent)
TODO move to NotificationService ?

Specified by:
getIssueActivity in interface IssueService

getAllIssueAttachmentCount

public Long getAllIssueAttachmentCount()
Specified by:
getAllIssueAttachmentCount in interface IssueService

getAllIssueAttachments

public List<IssueAttachment> getAllIssueAttachments()
Deprecated. do not use this due to expensive memory use! use explicit hsqldb queries instead.

Specified by:
getAllIssueAttachments in interface IssueService
Returns:

getIssueAttachment

public IssueAttachment getIssueAttachment(Integer attachmentId)
Specified by:
getIssueAttachment in interface IssueService

getIssueAttachmentData

public byte[] getIssueAttachmentData(Integer attachmentId)
Description copied from interface: IssueService
Returns the binary data for an attachment.

Specified by:
getIssueAttachmentData in interface IssueService
Parameters:
attachmentId - the id of the attachment to obtain the data for
Returns:
a byte array containing the attachment data

getIssueAttachmentCount

public int getIssueAttachmentCount(Integer issueId)
Specified by:
getIssueAttachmentCount in interface IssueService

getLastIssueHistory

public IssueHistory getLastIssueHistory(Integer issueId)
Returns the latest issue history entry for a particular issue.

Specified by:
getLastIssueHistory in interface IssueService
Parameters:
issueId - the id of the issue to return the history entry for.
Returns:
the latest IssueHistory, or null if no entries could be found

getOpenIssueCountByProjectId

public int getOpenIssueCountByProjectId(Integer projectId)
Specified by:
getOpenIssueCountByProjectId in interface IssueService

getResolvedIssueCountByProjectId

public int getResolvedIssueCountByProjectId(Integer projectId)
Specified by:
getResolvedIssueCountByProjectId in interface IssueService

getTotalIssueCountByProjectId

public int getTotalIssueCountByProjectId(Integer projectId)
Specified by:
getTotalIssueCountByProjectId in interface IssueService

getLatestIssueDateByProjectId

public Date getLatestIssueDateByProjectId(Integer projectId)
Specified by:
getLatestIssueDateByProjectId in interface IssueService

canViewIssue

public boolean canViewIssue(Integer issueId,
                            User user)
Specified by:
canViewIssue in interface IssueService

canViewIssue

public boolean canViewIssue(Issue issue,
                            User user)
Specified by:
canViewIssue in interface IssueService

getAllIssueAttachmentSize

public Long getAllIssueAttachmentSize()
get total size of all attachments in database

Specified by:
getAllIssueAttachmentSize in interface IssueService

searchIssues

public List<Issue> searchIssues(IssueSearchQuery queryModel,
                                User user,
                                Map<Integer,Set<PermissionType>> userPermissions)
                         throws IssueSearchException
Specified by:
searchIssues in interface IssueService
Throws:
IssueSearchException

totalSystemIssuesAttachmentSize

public Long totalSystemIssuesAttachmentSize()


Copyright © 2002-2012 itracker. All Rights Reserved.