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 */
020 package org.sonar.wsclient.services;
021
022 import java.util.Date;
023
024 public class Violation extends Model {
025
026 private Long id = null;
027 private String message = null;
028 private String severity = null;
029 private Integer line = null;
030 private String ruleKey = null;
031 private String ruleName = null;
032 private String resourceKey = null;
033 private String resourceName = null;
034 private String resourceScope = null;
035 private String resourceQualifier = null;
036 private Date createdAt = null;
037 private boolean switchedOff;
038 private Review review = null;
039
040 public String getMessage() {
041 return message;
042 }
043
044 public void setMessage(String message) {
045 this.message = message;
046 }
047
048 /**
049 * @since 2.5
050 */
051 public String getSeverity() {
052 return severity;
053 }
054
055 /**
056 * @since 2.5
057 */
058 public void setSeverity(String severity) {
059 this.severity = severity;
060 }
061
062 /**
063 * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829
064 */
065 @Deprecated
066 public String getPriority() {
067 return severity;
068 }
069
070 /**
071 * @deprecated since 2.5 use {@link #setSeverity(String)} instead. See http://jira.codehaus.org/browse/SONAR-1829
072 */
073 @Deprecated
074 public void setPriority(String priority) {
075 this.severity = priority;
076 }
077
078 /**
079 * @return line number (numeration starts from 1), or <code>null</code> if violation doesn't belong to concrete line
080 * @see #hasLine()
081 */
082 public Integer getLine() {
083 return line;
084 }
085
086 public void setLine(Integer line) {
087 if (line != null && line < 1) {
088 /*
089 * This shouldn't happen, however line would be normalized to null if web service returns incorrect value (less than 1) in compliance
090 * with a contract for getLine method. Normalization added in 2.8 - see http://jira.codehaus.org/browse/SONAR-2386
091 */
092 this.line = null;
093 } else {
094 this.line = line;
095 }
096 }
097
098 /**
099 * @return <code>true<code> if violation belongs to concrete line
100 * @since 2.8
101 */
102 public boolean hasLine() {
103 return line != null;
104 }
105
106 public String getResourceKey() {
107 return resourceKey;
108 }
109
110 public void setResourceKey(String resourceKey) {
111 this.resourceKey = resourceKey;
112 }
113
114 public String getRuleKey() {
115 return ruleKey;
116 }
117
118 public Violation setRuleKey(String s) {
119 this.ruleKey = s;
120 return this;
121 }
122
123 public String getRuleName() {
124 return ruleName;
125 }
126
127 public Violation setRuleName(String ruleName) {
128 this.ruleName = ruleName;
129 return this;
130 }
131
132 public String getResourceName() {
133 return resourceName;
134 }
135
136 public Violation setResourceName(String resourceName) {
137 this.resourceName = resourceName;
138 return this;
139 }
140
141 public String getResourceScope() {
142 return resourceScope;
143 }
144
145 public Violation setResourceScope(String resourceScope) {
146 this.resourceScope = resourceScope;
147 return this;
148 }
149
150 public String getResourceQualifier() {
151 return resourceQualifier;
152 }
153
154 public Violation setResourceQualifier(String resourceQualifier) {
155 this.resourceQualifier = resourceQualifier;
156 return this;
157 }
158
159 /**
160 * @since 2.5
161 */
162 public Date getCreatedAt() {
163 return createdAt;
164 }
165
166 /**
167 * @since 2.5
168 */
169 public Violation setCreatedAt(Date createdAt) {
170 this.createdAt = createdAt;
171 return this;
172 }
173
174 /**
175 * @since 2.5
176 */
177 public boolean isCreatedAfter(Date date) {
178 return createdAt != null && date != null && createdAt.after(date);
179 }
180
181 /**
182 * @since 2.8
183 */
184 public Violation setSwitchedOff(Boolean b) {
185 this.switchedOff = (b != null && b);
186 return this;
187 }
188
189 /**
190 * @since 2.8
191 */
192 public boolean isSwitchedOff() {
193 return switchedOff;
194 }
195
196 /**
197 * @since 2.8
198 */
199 public Review getReview() {
200 return review;
201 }
202
203 /**
204 * @since 2.8
205 */
206 public Violation setReview(Review review) {
207 this.review = review;
208 return this;
209 }
210
211 /**
212 * @since 2.9
213 */
214 public Long getId() {
215 return id;
216 }
217
218 /**
219 * @since 2.9
220 */
221 public void setId(Long id) {
222 this.id = id;
223 }
224 }