001    /*
002     * SonarQube, open source software quality management tool.
003     * Copyright (C) 2008-2013 SonarSource
004     * mailto:contact AT sonarsource DOT com
005     *
006     * SonarQube 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     * SonarQube 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 License
017     * along with this program; if not, write to the Free Software Foundation,
018     * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019     */
020    package org.sonar.wsclient.services;
021    
022    import java.util.Date;
023    
024    /**
025     * @deprecated in 3.6. Replaced by issues.
026     */
027    @Deprecated
028    public class Violation extends Model {
029    
030      private String message = null;
031      private String severity = null;
032      private Integer line = null;
033      private String ruleKey = null;
034      private String ruleName = null;
035      private String resourceKey = null;
036      private String resourceName = null;
037      private String resourceQualifier = null;
038      private Date createdAt = null;
039      private boolean switchedOff;
040    
041      public String getMessage() {
042        return message;
043      }
044    
045      public void setMessage(String message) {
046        this.message = message;
047      }
048    
049      /**
050       * @since 2.5
051       */
052      public String getSeverity() {
053        return severity;
054      }
055    
056      /**
057       * @since 2.5
058       */
059      public void setSeverity(String severity) {
060        this.severity = severity;
061      }
062    
063      /**
064       * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829
065       */
066      @Deprecated
067      public String getPriority() {
068        return severity;
069      }
070    
071      /**
072       * @deprecated since 2.5 use {@link #setSeverity(String)} instead. See http://jira.codehaus.org/browse/SONAR-1829
073       */
074      @Deprecated
075      public void setPriority(String priority) {
076        this.severity = priority;
077      }
078    
079      /**
080       * @return line number (numeration starts from 1), or <code>null</code> if violation doesn't belong to concrete line
081       * @see #hasLine()
082       */
083      public Integer getLine() {
084        return line;
085      }
086    
087      public void setLine(Integer line) {
088        if (line != null && line < 1) {
089          /*
090           * This shouldn't happen, however line would be normalized to null if web service returns incorrect value (less than 1) in compliance
091           * with a contract for getLine method. Normalization added in 2.8 - see http://jira.codehaus.org/browse/SONAR-2386
092           */
093          this.line = null;
094        } else {
095          this.line = line;
096        }
097      }
098    
099      /**
100       * @return <code>true<code> if violation belongs to concrete line
101       * @since 2.8
102       */
103      public boolean hasLine() {
104        return line != null;
105      }
106    
107      public String getResourceKey() {
108        return resourceKey;
109      }
110    
111      public void setResourceKey(String resourceKey) {
112        this.resourceKey = resourceKey;
113      }
114    
115      public String getRuleKey() {
116        return ruleKey;
117      }
118    
119      public Violation setRuleKey(String s) {
120        this.ruleKey = s;
121        return this;
122      }
123    
124      public String getRuleName() {
125        return ruleName;
126      }
127    
128      public Violation setRuleName(String ruleName) {
129        this.ruleName = ruleName;
130        return this;
131      }
132    
133      public String getResourceName() {
134        return resourceName;
135      }
136    
137      public Violation setResourceName(String resourceName) {
138        this.resourceName = resourceName;
139        return this;
140      }
141    
142      public String getResourceQualifier() {
143        return resourceQualifier;
144      }
145    
146      public Violation setResourceQualifier(String resourceQualifier) {
147        this.resourceQualifier = resourceQualifier;
148        return this;
149      }
150    
151      /**
152       * @since 2.5
153       */
154      public Date getCreatedAt() {
155        return createdAt;
156      }
157    
158      /**
159       * @since 2.5
160       */
161      public Violation setCreatedAt(Date createdAt) {
162        this.createdAt = createdAt;
163        return this;
164      }
165    
166      /**
167       * @since 2.5
168       */
169      public boolean isCreatedAfter(Date date) {
170        return createdAt != null && date != null && createdAt.after(date);
171      }
172    
173      /**
174       * @since 2.8
175       */
176      public Violation setSwitchedOff(Boolean b) {
177        this.switchedOff = (b != null && b);
178        return this;
179      }
180    
181      /**
182       * @since 2.8
183       */
184      public boolean isSwitchedOff() {
185        return switchedOff;
186      }
187    
188    }