View Javadoc

1   /*
2    * Sonar, entreprise quality control tool.
3    * Copyright (C) 2007-2008 Hortis-GRC SA
4    * mailto:be_agile HAT hortis DOT ch
5    *
6    * Sonar is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 3 of the License, or (at your option) any later version.
10   *
11   * Sonar is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with {library}; if not, write to the Free Software
18   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
19   */
20  package ch.hortis.sonar.model;
21  
22  import javax.persistence.*;
23  
24  @Entity
25  @Table(name = "rule_failure_params")
26  public class RuleFailureParam {
27    
28    public static final int PARAM_KEY_COLUMN_SIZE = 100;
29    
30    @Id
31    @Column(name = "id")
32    @SequenceGenerator(name= "RULE_FAILURE_PARAMS_SEQ", sequenceName = "RULE_FAILURE_PARAMS_SEQ")
33    @GeneratedValue(strategy = GenerationType.AUTO, generator = "RULE_FAILURE_PARAMS_SEQ")
34    private Integer id;
35  
36    @Column(name = "param_key", updatable = false, nullable = false, length = PARAM_KEY_COLUMN_SIZE)
37    private String key;
38  
39    @Column(name = "value", updatable = false, nullable = true, precision = 30, scale = 20)
40    private Double value;
41  
42    @Column(name = "value2", updatable = false, nullable = true, precision = 30, scale = 20)
43    private Double value2;
44  
45    @ManyToOne(fetch = FetchType.LAZY)
46    @JoinColumn(name = "rule_failure_id")
47    private RuleFailure ruleFailure;
48  
49    @Column(name = "snapshot_id")
50    protected Integer snapshotId;
51  
52    public RuleFailureParam(String key, Double value, Double value2) {
53      setKey(key);
54      this.value = value;
55      this.value2 = value2;
56    }
57  
58    public RuleFailureParam() {
59    }
60  
61    public Integer getId() {
62      return id;
63    }
64  
65    public void setId( Integer id ) {
66      this.id = id;
67    }
68  
69    public void setSnapshot(Snapshot snapshot) {
70      this.snapshotId = snapshot.getId();
71    }
72  
73    public RuleFailure getRuleFailure() {
74      return ruleFailure;
75    }
76  
77    public void setRuleFailure(RuleFailure ruleFailure) {
78      this.ruleFailure = ruleFailure;
79    }
80  
81    public String getKey() {
82      return key;
83    }
84  
85    public void setKey( String key ) {
86      if ( key.length() > PARAM_KEY_COLUMN_SIZE ) {
87        throw new IllegalArgumentException("RuleFailureParam key " + key + " size too long :" + key.length());
88      }
89      this.key = key;
90    }
91  
92    public Double getValue() {
93      return value;
94    }
95  
96    public void setValue( Double value ) {
97      this.value = value;
98    }
99  
100   public Double getValue2() {
101     return value2;
102   }
103 
104   public void setValue2( Double value2 ) {
105     this.value2 = value2;
106   }
107 }