Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
b0603d1b
Commit
b0603d1b
authored
Feb 05, 2024
by
Jeremie Bresson
Browse files
Merge remote-tracking branch 'origin/main' into 6.x
parents
7d0e3243
7b07abd0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/models/IssueFilter.java
View file @
b0603d1b
package
org.gitlab4j.api.models
;
package
org.gitlab4j.api.models
;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
org.gitlab4j.api.Constants
;
import
org.gitlab4j.api.Constants
;
import
org.gitlab4j.api.Constants.IssueOrderBy
;
import
org.gitlab4j.api.Constants.IssueOrderBy
;
...
@@ -8,6 +12,11 @@ import org.gitlab4j.api.Constants.IssueState;
...
@@ -8,6 +12,11 @@ import org.gitlab4j.api.Constants.IssueState;
import
org.gitlab4j.api.Constants.SortOrder
;
import
org.gitlab4j.api.Constants.SortOrder
;
import
org.gitlab4j.api.GitLabApiForm
;
import
org.gitlab4j.api.GitLabApiForm
;
import
org.gitlab4j.api.utils.ISO8601
;
import
org.gitlab4j.api.utils.ISO8601
;
import
org.gitlab4j.api.utils.JacksonJsonEnumHelper
;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonValue
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -99,6 +108,32 @@ public class IssueFilter implements Serializable {
...
@@ -99,6 +108,32 @@ public class IssueFilter implements Serializable {
*/
*/
private
String
iterationTitle
;
private
String
iterationTitle
;
/*
* Return issues without these parameters
*/
private
Map
<
IssueField
,
Object
>
not
;
public
enum
IssueField
{
ASSIGNEE_ID
,
ASSIGNEE_USERNAME
,
AUTHOR_ID
,
AUTHOR_USERNAME
,
IIDS
,
ITERATION_ID
,
ITERATION_TITLE
,
LABELS
,
MILESTONE
,
MILESTONE_ID
;
private
static
JacksonJsonEnumHelper
<
IssueField
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
IssueField
.
class
);
@JsonCreator
public
static
IssueField
forValue
(
String
value
)
{
return
enumHelper
.
forValue
(
value
);
}
@JsonValue
public
String
toValue
()
{
return
(
enumHelper
.
toString
(
this
));
}
@Override
public
String
toString
()
{
return
(
enumHelper
.
toString
(
this
));
}
}
/*- properties -*/
/*- properties -*/
public
List
<
String
>
getIids
()
{
public
List
<
String
>
getIids
()
{
...
@@ -229,6 +264,14 @@ public class IssueFilter implements Serializable {
...
@@ -229,6 +264,14 @@ public class IssueFilter implements Serializable {
this
.
iterationTitle
=
iterationTitle
;
this
.
iterationTitle
=
iterationTitle
;
}
}
public
Map
<
IssueField
,
Object
>
getNot
()
{
return
not
;
}
public
void
setNot
(
Map
<
IssueField
,
Object
>
not
)
{
this
.
not
=
not
;
}
/*- builder -*/
/*- builder -*/
public
IssueFilter
withIids
(
List
<
String
>
iids
)
{
public
IssueFilter
withIids
(
List
<
String
>
iids
)
{
this
.
iids
=
iids
;
this
.
iids
=
iids
;
...
@@ -310,6 +353,132 @@ public class IssueFilter implements Serializable {
...
@@ -310,6 +353,132 @@ public class IssueFilter implements Serializable {
return
(
this
);
return
(
this
);
}
}
/**
* Add 'not' filter.
*
* @param not the 'not' filter
* @return the reference to this IssueFilter instance
*/
public
IssueFilter
withNot
(
Map
<
IssueField
,
Object
>
not
)
{
this
.
not
=
not
;
return
(
this
);
}
/**
* Add 'not' filter entry.
*
* @param field the field to be added to the 'not' value
* @param value the value for the entry
* @return the reference to this IssueField instance
*/
public
IssueFilter
withNot
(
IssueField
field
,
Object
value
)
{
if
(
not
==
null
)
{
not
=
new
LinkedHashMap
<>();
}
not
.
put
(
field
,
value
);
return
(
this
);
}
/**
* Add labels to the 'not' filter entry.
*
* @param labels the labels to add to the filter
* @return the reference to this IssueFilter instance
*/
public
IssueFilter
withoutLabels
(
String
...
labels
)
{
return
withNot
(
IssueField
.
LABELS
,
String
.
join
(
","
,
labels
));
}
/*
* Add iids to the 'not' filter entry.
*
* @param iids the iids to add to the filter
* @return the reference to this IssueFilter instance
*/
public
IssueFilter
withoutIids
(
String
...
iids
)
{
return
withNot
(
IssueField
.
IIDS
,
String
.
join
(
","
,
iids
));
}
/**
* Add author_id to the 'not' filter entry.
*
* @param authorId the id of the author to add to the filter
* @return the reference to this IssueFilter instance
*/
public
IssueFilter
withoutAuthorId
(
Long
authorId
)
{
return
withNot
(
IssueField
.
AUTHOR_ID
,
authorId
);
}
/**
* Add author_username to the 'not' filter entry.
*
* @param authorUsername the username of the author to add to the filter
* @return the reference to this IssueFilter instance
*/
public
IssueFilter
withoutAuthorUsername
(
String
authorUsername
)
{
return
withNot
(
IssueField
.
AUTHOR_USERNAME
,
authorUsername
);
}
/**
* Add assignee_id to the 'not' filter entry.
*
* @param assigneeId the id of the assignee to add to the filter
* @return the reference to this IssueFilter instance
*/
public
IssueFilter
withoutAssigneeId
(
Long
assigneeId
)
{
return
withNot
(
IssueField
.
ASSIGNEE_ID
,
assigneeId
);
}
/**
* Add assignee_username to the 'not' filter entry.
*
* @param assigneeUsername the username of the assignee to add to the filter
* @return the reference to this IssueFilter instance
*/
public
IssueFilter
withoutAssigneeUsername
(
String
assigneeUsername
)
{
return
withNot
(
IssueField
.
ASSIGNEE_USERNAME
,
assigneeUsername
);
}
/**
* Add iteration_id to the 'not' filter entry.
*
* @param iterationId the id of the iteration to add to the filter
* @return the reference to this IssueFilter instance
*/
public
IssueFilter
withoutIterationId
(
Long
iterationId
)
{
return
withNot
(
IssueField
.
ITERATION_ID
,
iterationId
);
}
/**
* Add iteration_title to the 'not' filter entry.
*
* @param iterationTitle the title of the iteration to add to the filter
* @return the reference to this IssueFilter instance
*/
public
IssueFilter
withoutIterationTitle
(
String
iterationTitle
)
{
return
withNot
(
IssueField
.
ITERATION_TITLE
,
iterationTitle
);
}
/**
* Add milestone_id to the 'not' filter entry.
*
* @param milestoneId the id of the milestone to add to the filter
* @return the reference to this IssueFilter instance
*/
public
IssueFilter
withoutMilestoneId
(
Long
milestoneId
)
{
return
withNot
(
IssueField
.
MILESTONE_ID
,
milestoneId
);
}
/**
* Add milestone to the 'not' filter entry.
*
* @param milestone the title of the milestone to add to the filter
* @return the reference to this IssueFilter instance
*/
public
IssueFilter
withoutMilestone
(
String
milestone
)
{
return
withNot
(
IssueField
.
MILESTONE
,
milestone
);
}
/*- params generator -*/
/*- params generator -*/
@JsonIgnore
@JsonIgnore
public
GitLabApiForm
getQueryParams
(
int
page
,
int
perPage
)
{
public
GitLabApiForm
getQueryParams
(
int
page
,
int
perPage
)
{
...
@@ -336,6 +505,18 @@ public class IssueFilter implements Serializable {
...
@@ -336,6 +505,18 @@ public class IssueFilter implements Serializable {
.
withParam
(
"created_before"
,
ISO8601
.
toString
(
createdBefore
,
false
))
.
withParam
(
"created_before"
,
ISO8601
.
toString
(
createdBefore
,
false
))
.
withParam
(
"updated_after"
,
ISO8601
.
toString
(
updatedAfter
,
false
))
.
withParam
(
"updated_after"
,
ISO8601
.
toString
(
updatedAfter
,
false
))
.
withParam
(
"updated_before"
,
ISO8601
.
toString
(
updatedBefore
,
false
)))
.
withParam
(
"updated_before"
,
ISO8601
.
toString
(
updatedBefore
,
false
)))
.
withParam
(
"iteration_title"
,
iterationTitle
);
.
withParam
(
"iteration_title"
,
iterationTitle
)
.
withParam
(
"not"
,
toStringMap
(
not
),
false
);
}
private
Map
<
String
,
Object
>
toStringMap
(
Map
<
IssueField
,
Object
>
map
)
{
if
(
map
==
null
)
{
return
null
;
}
Map
<
String
,
Object
>
result
=
new
LinkedHashMap
<>();
for
(
Map
.
Entry
<
IssueField
,
Object
>
entry
:
map
.
entrySet
())
{
result
.
put
(
entry
.
getKey
().
toString
(),
entry
.
getValue
());
}
return
result
;
}
}
}
}
src/main/java/org/gitlab4j/api/models/MergeRequestFilter.java
View file @
b0603d1b
...
@@ -5,7 +5,9 @@ import static org.gitlab4j.api.Constants.MergeRequestScope.ASSIGNED_TO_ME;
...
@@ -5,7 +5,9 @@ import static org.gitlab4j.api.Constants.MergeRequestScope.ASSIGNED_TO_ME;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
org.gitlab4j.api.Constants
;
import
org.gitlab4j.api.Constants
;
import
org.gitlab4j.api.Constants.MergeRequestOrderBy
;
import
org.gitlab4j.api.Constants.MergeRequestOrderBy
;
...
@@ -15,8 +17,11 @@ import org.gitlab4j.api.Constants.MergeRequestState;
...
@@ -15,8 +17,11 @@ import org.gitlab4j.api.Constants.MergeRequestState;
import
org.gitlab4j.api.Constants.SortOrder
;
import
org.gitlab4j.api.Constants.SortOrder
;
import
org.gitlab4j.api.utils.JacksonJson
;
import
org.gitlab4j.api.utils.JacksonJson
;
import
org.gitlab4j.api.GitLabApiForm
;
import
org.gitlab4j.api.GitLabApiForm
;
import
org.gitlab4j.api.utils.JacksonJsonEnumHelper
;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonValue
;
/**
/**
* This class is used to filter merge requests when getting lists of them.
* This class is used to filter merge requests when getting lists of them.
...
@@ -50,6 +55,28 @@ public class MergeRequestFilter implements Serializable {
...
@@ -50,6 +55,28 @@ public class MergeRequestFilter implements Serializable {
private
String
search
;
private
String
search
;
private
MergeRequestSearchIn
in
;
private
MergeRequestSearchIn
in
;
private
Boolean
wip
;
private
Boolean
wip
;
private
Map
<
MergeRequestField
,
Object
>
not
;
public
enum
MergeRequestField
{
LABELS
,
MILESTONE
,
AUTHOR_ID
,
AUTHOR_USERNAME
,
ASSIGNEE_ID
,
ASSIGNEE_USERNAME
,
REVIEWER_ID
,
REVIEWER_USERNAME
,
MY_REACTION_EMOJI
;
private
static
JacksonJsonEnumHelper
<
MergeRequestField
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
MergeRequestField
.
class
);
@JsonCreator
public
static
MergeRequestField
forValue
(
String
value
)
{
return
enumHelper
.
forValue
(
value
);
}
@JsonValue
public
String
toValue
()
{
return
(
enumHelper
.
toString
(
this
));
}
@Override
public
String
toString
()
{
return
(
enumHelper
.
toString
(
this
));
}
}
public
Long
getProjectId
()
{
public
Long
getProjectId
()
{
return
projectId
;
return
projectId
;
...
@@ -337,6 +364,123 @@ public class MergeRequestFilter implements Serializable {
...
@@ -337,6 +364,123 @@ public class MergeRequestFilter implements Serializable {
return
(
this
);
return
(
this
);
}
}
/**
* Add 'not' filter.
*
* @param not the 'not' filter
* @return the reference to this MergeRequestFilter instance
*/
public
MergeRequestFilter
withNot
(
Map
<
MergeRequestField
,
Object
>
not
)
{
this
.
not
=
not
;
return
(
this
);
}
/**
* Add 'not' filter entry.
*
* @param field the field to be added to the 'not' value
* @param value the value for the entry
* @return the reference to this MergeRequestFilter instance
*/
public
MergeRequestFilter
withNot
(
MergeRequestField
field
,
Object
value
)
{
if
(
not
==
null
)
{
not
=
new
LinkedHashMap
<>();
}
not
.
put
(
field
,
value
);
return
(
this
);
}
/**
* Add author_id to the 'not' filter entry.
*
* @param authorId the id of the author to add to the filter
* @return the reference to this MergeRequestFilter instance
*/
public
MergeRequestFilter
withoutAuthorId
(
Long
authorId
)
{
return
withNot
(
MergeRequestField
.
AUTHOR_ID
,
authorId
);
}
/**
* Add author_username to the 'not' filter entry.
*
* @param authorUsername the username of the author to add to the filter
* @return the reference to this MergeRequestFilter instance
*/
public
MergeRequestFilter
withoutAuthorUsername
(
String
authorUsername
)
{
return
withNot
(
MergeRequestField
.
AUTHOR_USERNAME
,
authorUsername
);
}
/**
* Add assignee_id to the 'not' filter entry.
*
* @param assigneeId the id of the assignee to add to the filter
* @return the reference to this MergeRequestFilter instance
*/
public
MergeRequestFilter
withoutAssigneeId
(
Long
assigneeId
)
{
return
withNot
(
MergeRequestField
.
ASSIGNEE_ID
,
assigneeId
);
}
/**
* Add assignee_username to the 'not' filter entry.
*
* @param assigneeUsername the username of the assignee to add to the filter
* @return the reference to this MergeRequestFilter instance
*/
public
MergeRequestFilter
withoutAssigneeUsername
(
String
assigneeUsername
)
{
return
withNot
(
MergeRequestField
.
ASSIGNEE_USERNAME
,
assigneeUsername
);
}
/**
* Add reviewer_id to the 'not' filter entry.
*
* @param reviewerId the id of the reviewer to add to the filter
* @return the reference to this MergeRequestFilter instance
*/
public
MergeRequestFilter
withoutReviewerId
(
Long
reviewerId
)
{
return
withNot
(
MergeRequestField
.
REVIEWER_ID
,
reviewerId
);
}
/**
* Add reviewer_username to the 'not' filter entry.
*
* @param reviewerUsername the username of the reviewer to add to the filter
* @return the reference to this MergeRequestFilter instance
*/
public
MergeRequestFilter
withoutReviewerUsername
(
String
reviewerUsername
)
{
return
withNot
(
MergeRequestField
.
REVIEWER_USERNAME
,
reviewerUsername
);
}
/**
* Add my_reaction_emoji to the 'not' filter entry.
*
* @param myReactionEmoji the name of the reactionEmoji to add to the filter
* @return the reference to this MergeRequestFilter instance
*/
public
MergeRequestFilter
withoutMyReactionEmoji
(
String
myReactionEmoji
)
{
return
withNot
(
MergeRequestField
.
MY_REACTION_EMOJI
,
myReactionEmoji
);
}
/**
* Add milestone to the 'not' filter entry.
*
* @param milestone the name of the milestone to add to the filter
* @return the reference to this MergeRequestFilter instance
*/
public
MergeRequestFilter
withoutMilestone
(
String
milestone
)
{
return
withNot
(
MergeRequestField
.
MILESTONE
,
milestone
);
}
/**
* Add labels to the 'not' filter entry.
*
* @param labels the labels to add to the filter
* @return the reference to this MergeRequestFilter instance
*/
public
MergeRequestFilter
withoutLabels
(
String
...
labels
)
{
return
withNot
(
MergeRequestField
.
LABELS
,
String
.
join
(
","
,
labels
));
}
@JsonIgnore
@JsonIgnore
public
GitLabApiForm
getQueryParams
(
int
page
,
int
perPage
)
{
public
GitLabApiForm
getQueryParams
(
int
page
,
int
perPage
)
{
return
(
getQueryParams
()
return
(
getQueryParams
()
...
@@ -365,14 +509,26 @@ public class MergeRequestFilter implements Serializable {
...
@@ -365,14 +509,26 @@ public class MergeRequestFilter implements Serializable {
.
withParam
(
"target_branch"
,
targetBranch
)
.
withParam
(
"target_branch"
,
targetBranch
)
.
withParam
(
"search"
,
search
)
.
withParam
(
"search"
,
search
)
.
withParam
(
"in"
,
in
)
.
withParam
(
"in"
,
in
)
.
withParam
(
"wip"
,
(
wip
==
null
?
null
:
wip
?
"yes"
:
"no"
));
.
withParam
(
"wip"
,
(
wip
==
null
?
null
:
wip
?
"yes"
:
"no"
))
.
withParam
(
"not"
,
toStringMap
(
not
),
false
);
if
(
authorId
!=
null
&&
(
scope
==
ALL
||
scope
==
ASSIGNED_TO_ME
))
{
if
(
authorId
!=
null
&&
(
scope
==
ALL
||
scope
==
ASSIGNED_TO_ME
))
{
params
.
withParam
(
"author_id"
,
authorId
);
params
.
withParam
(
"author_id"
,
authorId
);
}
}
return
params
;
return
params
;
}
}
private
Map
<
String
,
Object
>
toStringMap
(
Map
<
MergeRequestField
,
Object
>
map
)
{
if
(
map
==
null
)
{
return
null
;
}
Map
<
String
,
Object
>
result
=
new
LinkedHashMap
<>();
for
(
Map
.
Entry
<
MergeRequestField
,
Object
>
entry
:
map
.
entrySet
())
{
result
.
put
(
entry
.
getKey
().
toString
(),
entry
.
getValue
());
}
return
result
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
(
JacksonJson
.
toJsonString
(
this
));
return
(
JacksonJson
.
toJsonString
(
this
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment