16
16
package com .b2international .snowowl .core .rest .commit ;
17
17
18
18
import java .util .List ;
19
- import java .util .Set ;
20
19
20
+ import org .springdoc .api .annotations .ParameterObject ;
21
21
import org .springframework .web .bind .annotation .GetMapping ;
22
22
import org .springframework .web .bind .annotation .PathVariable ;
23
23
import org .springframework .web .bind .annotation .RequestMapping ;
24
- import org .springframework .web .bind .annotation .RequestParam ;
25
24
25
+ import com .b2international .commons .CompareUtils ;
26
26
import com .b2international .index .revision .Commit ;
27
27
import com .b2international .snowowl .core .commit .CommitInfo ;
28
28
import com .b2international .snowowl .core .commit .CommitInfos ;
29
29
import com .b2international .snowowl .core .events .util .Promise ;
30
30
import com .b2international .snowowl .core .repository .RepositoryRequests ;
31
31
import com .b2international .snowowl .core .rest .AbstractRestService ;
32
- import com .google . common . base . Strings ;
32
+ import com .b2international . snowowl . core . rest . domain . ResourceSelectors ;
33
33
34
34
import io .swagger .v3 .oas .annotations .Operation ;
35
35
import io .swagger .v3 .oas .annotations .Parameter ;
@@ -59,69 +59,22 @@ public RepositoryCommitRestService(String repositoryId) {
59
59
@ ApiResponse (responseCode = "200" , description = "OK" )
60
60
})
61
61
@ GetMapping (produces = { AbstractRestService .JSON_MEDIA_TYPE })
62
- public Promise <CommitInfos > search (
63
- @ Parameter (description = "The author of the commit to match" )
64
- @ RequestParam (value ="author" , required =false )
65
- final String author ,
66
-
67
- @ Parameter (description = "The identifier(s) to match" )
68
- @ RequestParam (value ="id" , required =false )
69
- final Set <String > id ,
70
-
71
- @ Parameter (description = "Affected component identifier to match" )
72
- @ RequestParam (value ="affectedComponentId" , required =false )
73
- final String affectedComponentId ,
74
-
75
- @ Parameter (description = "Commit comment term to match" )
76
- @ RequestParam (value ="comment" , required =false )
77
- final String comment ,
78
-
79
- @ Parameter (description = "One or more branch paths to match" )
80
- @ RequestParam (value ="branch" , required =false )
81
- final List <String > branch ,
82
-
83
- @ Parameter (description = "Commit timestamp to match" )
84
- @ RequestParam (value ="timestamp" , required =false )
85
- final Long timestamp ,
86
-
87
- @ Parameter (description = "Minimum commit timestamp to search matches from" )
88
- @ RequestParam (value ="timestampFrom" , required =false )
89
- final Long timestampFrom ,
90
-
91
- @ Parameter (description = "Maximum commit timestamp to search matches to" )
92
- @ RequestParam (value ="timestampTo" , required =false )
93
- final Long timestampTo ,
94
-
95
- @ Parameter (description = "Expansion parameters" )
96
- @ RequestParam (value ="expand" , required =false )
97
- final String expand ,
98
-
99
- @ Parameter (description = "The search key to use for retrieving the next page of results" )
100
- @ RequestParam (value ="searchAfter" , required =false )
101
- final String searchAfter ,
102
-
103
- @ Parameter (description = "Sort keys" )
104
- @ RequestParam (value ="sort" , required =false )
105
- final List <String > sort ,
106
-
107
- @ Parameter (description = "The maximum number of items to return" )
108
- @ RequestParam (value ="limit" , defaultValue ="50" , required =false )
109
- final int limit ) {
62
+ public Promise <CommitInfos > search (CommitInfoRestSearch params ) {
110
63
return RepositoryRequests
111
64
.commitInfos ()
112
65
.prepareSearchCommitInfo ()
113
- .filterByIds (id )
114
- .filterByAuthor (author )
115
- .filterByAffectedComponent (affectedComponentId )
116
- .filterByComment (comment )
117
- .filterByBranches (branch )
118
- .filterByTimestamp (timestamp )
119
- .filterByTimestamp (timestampFrom , timestampTo )
120
- .setFields (Strings . isNullOrEmpty ( expand ) ? List .of (Commit .Fields .ID , Commit .Fields .AUTHOR , Commit .Fields .BRANCH , Commit .Fields .COMMENT , Commit .Fields .TIMESTAMP , Commit .Fields .GROUP_ID ) : null )
121
- .setExpand (expand )
122
- .setSearchAfter (searchAfter )
123
- .setLimit (limit )
124
- .sortBy (extractSortFields (sort ))
66
+ .filterByIds (params . getId () )
67
+ .filterByAuthor (params . getAuthor () )
68
+ .filterByAffectedComponent (params . getAffectedComponentId () )
69
+ .filterByComment (params . getComment () )
70
+ .filterByBranches (params . getBranch () )
71
+ .filterByTimestamp (params . getTimestamp () )
72
+ .filterByTimestamp (params . getTimestampFrom (), params . getTimestampTo () )
73
+ .setFields (CompareUtils . isEmpty ( params . getExpand () ) ? List .of (Commit .Fields .ID , Commit .Fields .AUTHOR , Commit .Fields .BRANCH , Commit .Fields .COMMENT , Commit .Fields .TIMESTAMP , Commit .Fields .GROUP_ID ) : null )
74
+ .setExpand (params . getExpand () )
75
+ .setSearchAfter (params . getSearchAfter () )
76
+ .setLimit (params . getLimit () )
77
+ .sortBy (extractSortFields (params . getSort () ))
125
78
.build (repositoryId )
126
79
.execute (getBus ());
127
80
}
@@ -139,13 +92,12 @@ public Promise<CommitInfo> get(
139
92
@ PathVariable (value ="commitId" )
140
93
final String commitId ,
141
94
142
- @ Parameter (description = "Expansion parameters" )
143
- @ RequestParam (value ="expand" , required =false )
144
- final String expand ) {
95
+ @ ParameterObject
96
+ final ResourceSelectors selectors ) {
145
97
return RepositoryRequests
146
98
.commitInfos ()
147
99
.prepareGetCommitInfo (commitId )
148
- .setExpand (expand )
100
+ .setExpand (selectors . getExpand () )
149
101
.build (repositoryId )
150
102
.execute (getBus ());
151
103
}
0 commit comments