src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt

changeset 292
703591e739f4
parent 284
671c1c8fbf1c
equal deleted inserted replaced
291:bcf05cccac6f 292:703591e739f4
555 setInt(1, project.id) 555 setInt(1, project.id)
556 setBoolean(2, includeDone) 556 setBoolean(2, includeDone)
557 queryAll { it.extractIssue() } 557 queryAll { it.extractIssue() }
558 } 558 }
559 559
560 override fun listIssues(project: Project, includeDone: Boolean, version: Version?, component: Component?): List<Issue> = 560 override fun listIssues(
561 project: Project,
562 includeDone: Boolean,
563 specificVersion: Boolean,
564 version: Version?,
565 specificComponent: Boolean,
566 component: Component?
567 ): List<Issue> =
561 withStatement( 568 withStatement(
562 """$issueQuery where i.project = ? and 569 """$issueQuery where i.project = ? and
563 (? or phase < 2) and 570 (? or phase < 2) and
564 (not ? or ? in (resolved, affected)) and (not ? or (resolved is null and affected is null)) and 571 (not ? or ? in (resolved, affected)) and (not ? or (resolved is null and affected is null)) and
565 (not ? or component = ?) and (not ? or component is null) 572 (not ? or component = ?) and (not ? or component is null)
566 """.trimIndent() 573 """.trimIndent()
567 ) { 574 ) {
568 fun <T : Entity> applyFilter(search: T?, fflag: Int, nflag: Int, idcol: Int) {
569 if (search == null) {
570 setBoolean(fflag, false)
571 setBoolean(nflag, false)
572 setInt(idcol, 0)
573 } else {
574 setBoolean(fflag, true)
575 setBoolean(nflag, false)
576 setInt(idcol, search.id)
577 }
578 }
579 setInt(1, project.id) 575 setInt(1, project.id)
580 setBoolean(2, includeDone) 576 setBoolean(2, includeDone)
581 applyFilter(version, 3, 5, 4) 577
582 applyFilter(component, 6, 8, 7) 578 setBoolean(3, specificVersion && version != null)
579 setInt(4, version?.id ?: 0)
580 setBoolean(5, specificVersion && version == null)
581
582 setBoolean(6, specificComponent && component != null)
583 setInt(7, component?.id ?: 0)
584 setBoolean(8, specificComponent && component == null)
583 585
584 queryAll { it.extractIssue() } 586 queryAll { it.extractIssue() }
585 } 587 }
586 588
587 override fun findIssue(id: Int): Issue? = 589 override fun findIssue(id: Int): Issue? =

mercurial