001/*
002 * Sonar, open source software quality management tool.
003 * Copyright (C) 2008-2012 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * Sonar is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * Sonar is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with Sonar; if not, write to the Free Software
018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
019 */
020package org.sonar.core.review;
021
022import com.google.common.base.Preconditions;
023import org.apache.commons.lang.builder.ToStringBuilder;
024import org.apache.commons.lang.builder.ToStringStyle;
025
026import javax.annotation.Nullable;
027import java.util.Date;
028
029/**
030 * @since 2.13
031 */
032public final class ReviewDto {
033
034  public static final String STATUS_OPEN = "OPEN";
035  public static final String STATUS_REOPENED = "REOPENED";
036  public static final String STATUS_RESOLVED = "RESOLVED";
037  public static final String STATUS_CLOSED = "CLOSED";
038
039  public static final String RESOLUTION_FALSE_POSITIVE = "FALSE-POSITIVE";
040  public static final String RESOLUTION_FIXED = "FIXED";
041
042  private Long id;
043  private Integer userId;
044  private Long assigneeId;
045  private String title;
046  private String status;
047  private String resolution;
048  private Integer violationPermanentId;
049  private Integer projectId;
050  private Integer resourceId;
051  private Integer line;
052  private Date createdAt;
053  private Date updatedAt;
054  private String severity;
055  private Integer ruleId;
056  private boolean manualViolation;
057  private boolean manualSeverity;
058  private Integer actionPlanId;
059  private String data;
060
061  public Long getId() {
062    return id;
063  }
064
065  public ReviewDto setId(Long id) {
066    this.id = id;
067    return this;
068  }
069
070  public Integer getUserId() {
071    return userId;
072  }
073
074  public ReviewDto setUserId(Integer userId) {
075    this.userId = userId;
076    return this;
077  }
078
079  public Long getAssigneeId() {
080    return assigneeId;
081  }
082
083  public ReviewDto setAssigneeId(@Nullable Long assigneeId) {
084    this.assigneeId = assigneeId;
085    return this;
086  }
087
088  public String getTitle() {
089    return title;
090  }
091
092  public ReviewDto setTitle(String title) {
093    this.title = title;
094    return this;
095  }
096
097  public String getStatus() {
098    return status;
099  }
100
101  public ReviewDto setStatus(@Nullable String status) {
102    this.status = status;
103    return this;
104  }
105
106  public String getResolution() {
107    return resolution;
108  }
109
110  public ReviewDto setResolution(@Nullable String resolution) {
111    this.resolution = resolution;
112    return this;
113  }
114
115  public Integer getViolationPermanentId() {
116    return violationPermanentId;
117  }
118
119  public ReviewDto setViolationPermanentId(Integer violationPermanentId) {
120    this.violationPermanentId = violationPermanentId;
121    return this;
122  }
123
124  public Integer getProjectId() {
125    return projectId;
126  }
127
128  public ReviewDto setProjectId(Integer projectId) {
129    this.projectId = projectId;
130    return this;
131  }
132
133  public Integer getResourceId() {
134    return resourceId;
135  }
136
137  public ReviewDto setResourceId(Integer resourceId) {
138    this.resourceId = resourceId;
139    return this;
140  }
141
142  public Integer getLine() {
143    return line;
144  }
145
146  public ReviewDto setLine(@Nullable Integer line) {
147    this.line = line;
148    return this;
149  }
150
151  public Date getCreatedAt() {
152    return createdAt;
153  }
154
155  public ReviewDto setCreatedAt(Date createdAt) {
156    this.createdAt = createdAt;
157    return this;
158  }
159
160  public Date getUpdatedAt() {
161    return updatedAt;
162  }
163
164  public ReviewDto setUpdatedAt(Date updatedAt) {
165    this.updatedAt = updatedAt;
166    return this;
167  }
168
169  public String getSeverity() {
170    return severity;
171  }
172
173  public ReviewDto setSeverity(@Nullable String severity) {
174    this.severity = severity;
175    return this;
176  }
177
178  public Integer getRuleId() {
179    return ruleId;
180  }
181
182  public ReviewDto setRuleId(Integer ruleId) {
183    this.ruleId = ruleId;
184    return this;
185  }
186
187  public boolean getManualViolation() {
188    return manualViolation;
189  }
190
191  public boolean isManualViolation() {
192    return manualViolation;
193  }
194
195  public ReviewDto setManualViolation(boolean b) {
196    this.manualViolation = b;
197    return this;
198  }
199
200  public boolean getManualSeverity() {
201    return manualSeverity;
202  }
203
204  public ReviewDto setManualSeverity(boolean b) {
205    this.manualSeverity = b;
206    return this;
207  }
208
209  public boolean isManualSeverity() {
210    return manualSeverity;
211  }
212
213  public Integer getActionPlanId() {
214    return actionPlanId;
215  }
216
217  public ReviewDto setActionPlanId(@Nullable Integer i) {
218    this.actionPlanId = i;
219    return this;
220  }
221
222  public String getData() {
223    return data;
224  }
225
226  public ReviewDto setData(String s) {
227    Preconditions.checkArgument(s == null || s.length() <= 4000,
228        "Review data must not exceed 4000 characters: " + s);
229    this.data = s;
230    return this;
231  }
232
233  @Override
234  public String toString() {
235    return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
236  }
237
238  @Override
239  public boolean equals(Object o) {
240    if (this == o) {
241      return true;
242    }
243    if (o == null || getClass() != o.getClass()) {
244      return false;
245    }
246
247    ReviewDto reviewDto = (ReviewDto) o;
248    return !(id != null ? !id.equals(reviewDto.id) : reviewDto.id != null);
249  }
250
251  @Override
252  public int hashCode() {
253    return id != null ? id.hashCode() : 0;
254  }
255}