1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.theplugin.idea.crucible;
18
19 import com.atlassian.theplugin.commons.VirtualFileSystem;
20 import com.atlassian.theplugin.commons.cfg.CrucibleServerCfg;
21 import com.atlassian.theplugin.commons.crucible.ValueNotYetInitialized;
22 import com.atlassian.theplugin.commons.crucible.api.model.*;
23
24 import java.util.Date;
25 import java.util.List;
26
27 public class ReviewAdapter {
28 private Review review;
29 private CrucibleServerCfg server;
30 private static final int HASHCODE_MAGIC = 31;
31
32 public ReviewAdapter(Review review, CrucibleServerCfg server) {
33 this.review = review;
34 this.server = server;
35 }
36
37 public User getAuthor() {
38 return review.getAuthor();
39 }
40
41 public User getCreator() {
42 return review.getCreator();
43 }
44
45 public String getDescription() {
46 return review.getDescription();
47 }
48
49 public User getModerator() {
50 return review.getModerator();
51 }
52
53 public String getName() {
54 return review.getName();
55 }
56
57 public PermId getParentReview() {
58 return review.getParentReview();
59 }
60
61 public PermId getPermId() {
62 return review.getPermId();
63 }
64
65 public String getProjectKey() {
66 return review.getProjectKey();
67 }
68
69 public String getRepoName() {
70 return review.getRepoName();
71 }
72
73 public State getState() {
74 return review.getState();
75 }
76
77 public boolean isAllowReviewerToJoin() {
78 return review.isAllowReviewerToJoin();
79 }
80
81 public int getMetricsVersion() {
82 return review.getMetricsVersion();
83 }
84
85 public Date getCreateDate() {
86 return review.getCreateDate();
87 }
88
89 public Date getCloseDate() {
90 return review.getCloseDate();
91 }
92
93 public String getSummary() {
94 return review.getSummary();
95 }
96
97 public List<Reviewer> getReviewers() throws ValueNotYetInitialized {
98 return review.getReviewers();
99 }
100
101 public List<GeneralComment> getGeneralComments() throws ValueNotYetInitialized {
102 return review.getGeneralComments();
103 }
104
105 public List<VersionedComment> getVersionedComments() throws ValueNotYetInitialized {
106 return review.getVersionedComments();
107 }
108
109
110
111
112
113 public String getServerUrl() {
114 return review.getServerUrl();
115 }
116
117 public List<Action> getTransitions() throws ValueNotYetInitialized {
118 return review.getTransitions();
119 }
120
121 public List<Action> getActions() throws ValueNotYetInitialized {
122 return review.getActions();
123 }
124
125 public VirtualFileSystem getVirtualFileSystem() {
126 return review.getVirtualFileSystem();
127 }
128
129 public List<CrucibleReviewItemInfo> getReviewItems() {
130 return review.getReviewItems();
131 }
132
133 public CrucibleFileInfo getFileByPermId(PermId id) {
134 return review.getFileByPermId(id);
135 }
136
137 public CrucibleFileInfo getFileByReviewInfo(CrucibleReviewItemInfo info) {
138 return review.getFileByReviewInfo(info);
139 }
140
141 public CrucibleServerCfg getServer() {
142 return server;
143 }
144
145 public String getReviewUrl() {
146 String baseUrl = server.getUrl();
147 while (baseUrl.length() > 0 && baseUrl.charAt(baseUrl.length() - 1) == '/') {
148
149 baseUrl = baseUrl.substring(0, baseUrl.length() - 1);
150 }
151 return baseUrl + "/cru/" + getPermId().getId();
152 }
153
154 public Review getInnerReviewObject() {
155 return review;
156 }
157
158 @Override
159 public boolean equals(Object o) {
160 if (this == o) {
161 return true;
162 }
163 if (o == null || getClass() != o.getClass()) {
164 return false;
165 }
166
167 ReviewAdapter that = (ReviewAdapter) o;
168
169 if (review != null ? !review.equals(that.review) : that.review != null) {
170 return false;
171 }
172 if (server != null ? !server.equals(that.server) : that.server != null) {
173 return false;
174 }
175
176 return true;
177 }
178
179 @Override
180 public int hashCode() {
181 int result;
182 result = (review != null ? review.hashCode() : 0);
183 result = HASHCODE_MAGIC * result + (server != null ? server.hashCode() : 0);
184 return result;
185 }
186
187 public void setGeneralComments(final List<GeneralComment> generalComments) {
188 review.setGeneralComments(generalComments);
189 }
190
191 public void removeGeneralComment(final GeneralComment comment) {
192 review.removeGeneralComment(comment);
193 }
194
195 public void removeVersionedComment(final VersionedComment versionedComment) {
196 review.removeVersionedComment(versionedComment);
197 }
198 }