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 Sonar; 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 org.apache.commons.lang.builder.EqualsBuilder;
23  
24  import javax.persistence.*;
25  
26  @Entity
27  @Table(name = "snapshot_sources")
28  public class SnapshotSource {
29  
30    @Id
31    @Column(name = "id")
32    @SequenceGenerator(name = "SNAPSHOT_SOURCES_SEQ", sequenceName = "SNAPSHOT_SOURCES_SEQ")
33    @GeneratedValue(strategy = GenerationType.AUTO, generator = "SNAPSHOT_SOURCES_SEQ")
34    private Integer id;
35  
36    @Column(name = "snapshot_id")
37    private Integer snapshotId;
38  
39    @Lob
40    @Column(name = "data", updatable = true, nullable = true, length = 16777215)
41    private String data;
42  
43    public SnapshotSource() {
44    }
45  
46    public SnapshotSource(Snapshot snapshot, String data) {
47      this.snapshotId = snapshot.getId();
48      this.data = data;
49    }
50  
51    public Integer getId() {
52      return id;
53    }
54  
55    public void setId(Integer id) {
56      this.id = id;
57    }
58  
59    public void setSnapshot(Snapshot snapshot) {
60      this.snapshotId = snapshot.getId();
61    }
62  
63    public String getData() {
64      return data;
65    }
66  
67    public void setData(String data) {
68      this.data = data;
69    }
70  
71    public boolean equals(Object obj) {
72      if (!(obj instanceof SnapshotSource)) {
73        return false;
74      }
75      if (this == obj) {
76        return true;
77      }
78      SnapshotSource other = (SnapshotSource) obj;
79      return snapshotId.equals(other.snapshotId);
80    }
81  
82    public int hashCode() {
83      return snapshotId.hashCode();
84    }
85  }