Skip to content

Commit

Permalink
resolve dependencies problem and user Service
Browse files Browse the repository at this point in the history
  • Loading branch information
Draskovits Stefan committed Jan 29, 2017
1 parent 49365d8 commit 73e77dc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ open class TicketTagController @Inject constructor(
) {
@PostMapping
open fun createTicketTag(@RequestBody req: CreateTicketTagRequestJson): TicketTagResultJson {
val ticketTag = ticketTagService.createTicketTag(CreateTicketTag(req.name, req.color, req.order,req.autoClose), req.ticketTagGroupId)
val ticketTag = ticketTagService.createTicketTag(CreateTicketTag(req.name, req.color, req.order, req.autoClose), req.ticketTagGroupId)
return TicketTagResultJson(ticketTag)
}

@PutMapping(value = "/{id}")
open fun updateTicketTag(@PathVariable(name = "id") id: UUID,
@RequestBody req: UpdateTicketTagRequestJson
): TicketTagResultJson {
val ticketTag = ticketTagService.updateTicketTag(id, UpdateTicketTag(req.name, req.color, req.order, req.ticketTagGroupId,req.autoClose))
val ticketTag = ticketTagService.updateTicketTag(id, UpdateTicketTag(req.name, req.color, req.order, req.ticketTagGroupId, req.autoClose))
return TicketTagResultJson(ticketTag)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ open class CommandServiceImpl(
private val timeCategories: TimeCategoryRepository,
private val assignmentTags: AssignmentTagRepository,
private val nn: NameNormalizationLibrary,
private val ticketTagRelationService: TicketTagRelationService,
private val ticketAssignmentService: TicketAssignmentService
) : CommandService {
@Inject()
private lateinit var ticketService: TicketService

@Inject()
private lateinit var ticketTagRelationService: TicketTagRelationService

@PreAuthorize(AuthExpr.USER)
override fun applyCommands(comment: Comment, @Valid commands: List<Command>, principal: Principal) {
val errors = mutableListOf<ValidationError>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ open class TicketServiceImpl @Inject constructor(
private val comments: CommentRepository,
private val assignments: TicketAssignmentRepository,
private val ticketAssignmentService: TicketAssignmentService,
private val commandService: CommandService,
private val ticketEvents: TicketEventRepository
) : TicketService {

@Inject()
private lateinit var commandService: CommandService
companion object {
private val LOG = LoggerFactory.getLogger(TicketServiceImpl::class.java)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import io.ticktag.persistence.ticket.entity.TicketEventTagRemoved
import io.ticktag.persistence.tickettag.TicketTagRepository
import io.ticktag.persistence.user.UserRepository
import io.ticktag.service.*
import io.ticktag.service.ticket.dto.UpdateTicket
import io.ticktag.service.ticket.service.TicketService
import io.ticktag.service.tickettagrelation.dto.TicketTagRelationResult
import io.ticktag.service.tickettagrelation.services.TicketTagRelationService
import org.springframework.security.access.method.P
import org.springframework.security.access.prepost.PreAuthorize
import java.util.*
import javax.inject.Inject

@TicktagService
open class TicketTagRelationServiceImpl(
Expand All @@ -23,7 +26,8 @@ open class TicketTagRelationServiceImpl(
private val users: UserRepository,
private val kanbanCellRepository: KanbanCellRepository
) : TicketTagRelationService {

@Inject()
private lateinit var ticketService: TicketService
@PreAuthorize(AuthExpr.READ_TICKET_TAG_RELATION)
override fun getTicketTagRelation(@P("authTicketId") ticketId: UUID, tagId: UUID): TicketTagRelationResult {
val ticket = tickets.findOne(ticketId) ?: throw NotFoundException()
Expand All @@ -37,7 +41,7 @@ open class TicketTagRelationServiceImpl(
val ticket = tickets.findOne(ticketId) ?: throw NotFoundException()
val tag = tags.findOne(tagId) ?: throw NotFoundException()

if(tag.disabled)
if (tag.disabled)
throw TicktagValidationException(listOf(ValidationError("tag", ValidationErrorDetail.Other("tagDisabled"))))


Expand All @@ -62,7 +66,8 @@ open class TicketTagRelationServiceImpl(
ticket.tags.add(tag)
}
if (tag.autoClose) {
ticket.open = false
ticketService.updateTicket(UpdateTicket(open = UpdateValue(false), commands = null, currentEstimatedTime = null, description = null, dueDate = null, initialEstimatedTime = null, parentTicket = null, storyPoints = null, title = null), ticket.id, principal)

}

return TicketTagRelationResult(ticketId = ticket.id, tagId = tag.id)
Expand Down

0 comments on commit 73e77dc

Please sign in to comment.