Showing
4 changed files
with
72 additions
and
15 deletions
... | ... | @@ -63,7 +63,7 @@ |
63 | 63 | </executions> |
64 | 64 | <configuration> |
65 | 65 | <packageName>pl.com.it_crowd.youtrack.api.rest</packageName> |
66 | - <outputDirectory>${build.sourceDirectory}</outputDirectory> | |
66 | + <outputDirectory>${project.build.sourceDirectory}</outputDirectory> | |
67 | 67 | <clearOutputDir>false</clearOutputDir> |
68 | 68 | <extension>false</extension> |
69 | 69 | </configuration> |
... | ... |
... | ... | @@ -58,7 +58,7 @@ public final class Filter { |
58 | 58 | return new Filter().resolved(date); |
59 | 59 | } |
60 | 60 | |
61 | - public static Filter stateFilter(StateValues state) | |
61 | + public static Filter stateFilter(StateValues... state) | |
62 | 62 | { |
63 | 63 | return new Filter().state(state); |
64 | 64 | } |
... | ... | @@ -191,9 +191,13 @@ public final class Filter { |
191 | 191 | return this; |
192 | 192 | } |
193 | 193 | |
194 | - public Filter state(StateValues state) | |
194 | + public Filter state(StateValues... state) | |
195 | 195 | { |
196 | - return state(state.getFilterValue()); | |
196 | + final StringBuilder stringBuilder = new StringBuilder(); | |
197 | + for (StateValues value : state) { | |
198 | + stringBuilder.append(",").append(value.getFilterValue()); | |
199 | + } | |
200 | + return state(stringBuilder.length() > 0 ? stringBuilder.substring(1) : stringBuilder.toString()); | |
197 | 201 | } |
198 | 202 | |
199 | 203 | public Filter summary(String summary) |
... | ... |
1 | 1 | package pl.com.it_crowd.youtrack.api.defaults; |
2 | 2 | |
3 | 3 | public enum StateValues { |
4 | - Submitted, Open, InProgress("{In Progress}", "In Progress"), ToBeDiscussed("{To be discussed}", "To be discussed"), Reopened, CantReproduce( | |
5 | - "{Can't Reproduce}", "Can't Reproduce"), Duplicate, Fixed, WontFix("{Won't fix}", "Won't fix"), | |
6 | - Incomplete, Obsolete, Verified, New, Resolved("Resolved", null), Unresolved("Unresolved", null); | |
4 | + Submitted, | |
5 | + Open, | |
6 | + InProgress("{In Progress}", "In Progress"), | |
7 | + ToBeDiscussed("{To be discussed}", "To be discussed"), | |
8 | + Reopened, | |
9 | + CantReproduce("{Can't Reproduce}", "Can't Reproduce"), | |
10 | + Duplicate, | |
11 | + Fixed, | |
12 | + WontFix("{Won't fix}", "Won't fix"), | |
13 | + Incomplete, | |
14 | + Obsolete, | |
15 | + Verified, | |
16 | + New, | |
17 | + NotSubmitted(true, Submitted), | |
18 | + NotOpen(true, Open), | |
19 | + NotInProgress(true, InProgress), | |
20 | + NotToBeDiscussed(true, ToBeDiscussed), | |
21 | + NotReopened(true, Reopened), | |
22 | + NotCantReproduce(true, CantReproduce), | |
23 | + NotDuplicate(true, Duplicate), | |
24 | + NotFixed(true, Fixed), | |
25 | + NotWontFix(true, WontFix), | |
26 | + NotIncomplete(true, Incomplete), | |
27 | + NotObsolete(true, Open), | |
28 | + NotVerified(true, Verified), | |
29 | + NotNew(true, New), | |
30 | + Resolved("Resolved", null), | |
31 | + Unresolved("Unresolved", null); | |
7 | 32 | |
8 | 33 | // ------------------------------ FIELDS ------------------------------ |
9 | 34 | |
... | ... | @@ -11,29 +36,54 @@ public enum StateValues { |
11 | 36 | |
12 | 37 | private String filterValue; |
13 | 38 | |
39 | + private boolean not; | |
40 | + | |
14 | 41 | // --------------------------- CONSTRUCTORS --------------------------- |
15 | 42 | |
16 | 43 | private StateValues() |
17 | 44 | { |
18 | - filterValue = name(); | |
19 | - commandValue = name(); | |
45 | + this(false); | |
46 | + } | |
47 | + | |
48 | + private StateValues(boolean not) | |
49 | + { | |
50 | + this(not, null, null); | |
20 | 51 | } |
21 | 52 | |
22 | 53 | private StateValues(String filterValue, String commandValue) |
23 | 54 | { |
24 | - this.filterValue = filterValue; | |
25 | - this.commandValue = commandValue; | |
55 | + this(false, filterValue, commandValue); | |
56 | + } | |
57 | + | |
58 | + private StateValues(boolean not, StateValues value) | |
59 | + { | |
60 | + this(not, value.getFilterValue(), value.getCommandValue()); | |
61 | + } | |
62 | + | |
63 | + private StateValues(boolean not, String filterValue, String commandValue) | |
64 | + { | |
65 | + this.not = not; | |
66 | + this.filterValue = filterValue == null ? name() : filterValue; | |
67 | + this.commandValue = commandValue == null ? name() : commandValue; | |
68 | + } | |
69 | + | |
70 | +// ------------------------ CANONICAL METHODS ------------------------ | |
71 | + | |
72 | + @Override | |
73 | + public String toString() | |
74 | + { | |
75 | + return getCommandValue(); | |
26 | 76 | } |
27 | 77 | |
28 | -// --------------------- GETTER / SETTER METHODS --------------------- | |
78 | +// -------------------------- OTHER METHODS -------------------------- | |
29 | 79 | |
30 | 80 | public String getCommandValue() |
31 | 81 | { |
32 | - return commandValue; | |
82 | + return (not ? "-" : "") + commandValue; | |
33 | 83 | } |
34 | 84 | |
35 | 85 | public String getFilterValue() |
36 | 86 | { |
37 | - return filterValue; | |
87 | + return (not ? "-" : "") + filterValue; | |
38 | 88 | } |
39 | 89 | } |
... | ... |
... | ... | @@ -119,6 +119,10 @@ public class FilterTest { |
119 | 119 | Assert.assertEquals("state:" + encodeURL("Obsolete"), Filter.stateFilter(StateValues.Obsolete).toString()); |
120 | 120 | Assert.assertEquals("state:" + encodeURL("Open"), Filter.stateFilter(StateValues.Open).toString()); |
121 | 121 | Assert.assertEquals("state:" + encodeURL("{Won't fix}"), Filter.stateFilter(StateValues.WontFix).toString()); |
122 | + Assert.assertEquals("state:" + encodeURL("-{Won't fix}"), Filter.stateFilter(StateValues.NotWontFix).toString()); | |
123 | + Assert.assertEquals("state:" + encodeURL("-Verified"), Filter.stateFilter(StateValues.NotVerified).toString()); | |
124 | + Assert.assertEquals("state:" + encodeURL("-Verified,{Can't Reproduce},Obsolete,{Won't fix}"), | |
125 | + Filter.stateFilter(StateValues.NotVerified, StateValues.CantReproduce, StateValues.Obsolete, StateValues.WontFix).toString()); | |
122 | 126 | } |
123 | 127 | |
124 | 128 | @Test |
... | ... | @@ -143,7 +147,6 @@ public class FilterTest { |
143 | 147 | } |
144 | 148 | |
145 | 149 | @Test |
146 | - | |
147 | 150 | public void updaterFilter() |
148 | 151 | { |
149 | 152 | Assert.assertEquals("updated by:bernard", Filter.updaterFilter("bernard").toString()); |
... | ... |
Please
register
or
login
to post a comment