1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.maven.bugzilla.command;
17
18 import org.apache.maven.artifact.versioning.ArtifactVersion;
19 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
20 import org.codehaus.plexus.util.StringUtils;
21
22 import de.smartics.maven.issue.command.AddComponentCommand;
23 import de.smartics.maven.issue.command.AddMilestoneCommand;
24 import de.smartics.maven.issue.command.AddProductCommand;
25 import de.smartics.maven.issue.command.AddVersionCommand;
26 import de.smartics.maven.issue.command.ClassificationNavigationCommand;
27 import de.smartics.maven.issue.command.CommandArgument;
28 import de.smartics.maven.issue.command.CommandFactory;
29 import de.smartics.maven.issue.command.LoginCommand;
30 import de.smartics.maven.issue.command.LogoutCommand;
31 import de.smartics.maven.issue.command.ProductNavigationCommand;
32 import de.smartics.maven.issue.command.UpdateProductCommand;
33
34
35
36
37 public final class BugzillaCommandFactory implements CommandFactory
38 {
39
40
41
42
43
44
45
46
47
48
49 private final String issueServerVersion;
50
51
52
53
54
55
56
57
58
59
60 public BugzillaCommandFactory(final String issueServerVersion)
61 {
62 this.issueServerVersion = issueServerVersion;
63 }
64
65
66
67
68
69
70
71
72
73
74
75 @Override
76 public ClassificationNavigationCommand createClassificationNavigationCommand(
77 final String service,
78 final CommandArgument<ClassificationNavigationCommand> classification)
79 {
80 return new BugzillaClassificationNavigationCommand(service, classification);
81 }
82
83 @Override
84 public ProductNavigationCommand createProductNavigationCommand(
85 final String service,
86 final CommandArgument<ProductNavigationCommand> product)
87 {
88 return new BugzillaProductNavigationCommand(service, product);
89 }
90
91 @Override
92 public ProductNavigationCommand createProductNavigationCommand(
93 final String service,
94 final CommandArgument<ProductNavigationCommand> action,
95 final CommandArgument<ProductNavigationCommand> product)
96 {
97 return new BugzillaProductNavigationCommand(service, action, product);
98 }
99
100 @Override
101 public AddVersionCommand createAddVersionCommand(
102 final CommandArgument<AddVersionCommand> product,
103 final CommandArgument<AddVersionCommand> version,
104 final CommandArgument<AddVersionCommand> token)
105 {
106 return new BugzillaAddVersionCommand(product, version, token);
107 }
108
109 @Override
110 public AddMilestoneCommand createAddMilestoneCommand(
111 final CommandArgument<AddMilestoneCommand> product,
112 final CommandArgument<AddMilestoneCommand> milestone,
113 final CommandArgument<AddMilestoneCommand> sortkey,
114 final CommandArgument<AddMilestoneCommand> token)
115 {
116 return new BugzillaAddMilestoneCommand(product, milestone, sortkey, token);
117 }
118
119
120
121
122
123
124
125
126 @Override
127 public LoginCommand createLoginCommand(
128 final CommandArgument<LoginCommand> login,
129 final CommandArgument<LoginCommand> password)
130 {
131 return new BugzillaLoginCommand(login, password);
132 }
133
134 @Override
135 public LogoutCommand createLogoutCommand()
136 {
137 return new BugzillaLogoutCommand();
138 }
139
140
141 @Override
142 public AddProductCommand createAddProductCommand(
143
144 final CommandArgument<AddProductCommand> classification,
145 final CommandArgument<AddProductCommand> product,
146 final CommandArgument<AddProductCommand> description,
147 final CommandArgument<AddProductCommand> defaultMilestone,
148 final CommandArgument<AddProductCommand> version,
149 final CommandArgument<AddProductCommand> token)
150 {
151 return new BugzillaAddProductCommand(classification, product, description,
152 defaultMilestone, version, token, null, null, null);
153 }
154
155
156
157
158 @Override
159 public UpdateProductCommand createUpdateProductCommand(
160 final CommandArgument<UpdateProductCommand> oldProduct,
161 final CommandArgument<UpdateProductCommand> product,
162 final CommandArgument<UpdateProductCommand> description,
163 final CommandArgument<UpdateProductCommand> defaultMilestone,
164 final CommandArgument<UpdateProductCommand> token)
165 {
166 return new BugzillaUpdateProductCommand(oldProduct, product, description,
167 defaultMilestone, token);
168 }
169
170
171 @Override
172 public AddComponentCommand createAddComponentCommand(
173 final CommandArgument<AddComponentCommand> product,
174 final CommandArgument<AddComponentCommand> component,
175 final CommandArgument<AddComponentCommand> description,
176 final CommandArgument<AddComponentCommand> initialOwner,
177 final CommandArgument<AddComponentCommand> token)
178 {
179 return new BugzillaAddComponentCommand(product, component, description,
180 initialOwner, token);
181 }
182
183
184 @Override
185 public AddProductCommand createAddProductCommand(
186 final CommandArgument<AddProductCommand> classification,
187 final CommandArgument<AddProductCommand> product,
188 final CommandArgument<AddProductCommand> description,
189 final CommandArgument<AddProductCommand> defaultMilestone,
190 final CommandArgument<AddProductCommand> version,
191 final CommandArgument<AddProductCommand> token,
192 final CommandArgument<AddProductCommand> component,
193 final CommandArgument<AddProductCommand> componentDescription,
194 final CommandArgument<AddProductCommand> componentInitialOwner)
195 {
196 return new BugzillaAddProductCommand(classification, product, description,
197 defaultMilestone, version, token, component, componentDescription,
198 componentInitialOwner);
199 }
200
201
202 @Override
203 public boolean requiresComponentOnProductCreation()
204 {
205 if (StringUtils.isNotBlank(issueServerVersion))
206 {
207 final ArtifactVersion version =
208 new DefaultArtifactVersion(issueServerVersion);
209 final boolean requires =
210 (version.getMajorVersion() >= 4 && version.getMinorVersion() >= 4);
211 return requires;
212 }
213 return false;
214 }
215
216
217
218 }