001 /*
002 * Sonar, open source software quality management tool.
003 * Copyright (C) 2009 SonarSource SA
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.api.database.model;
021
022 import org.sonar.api.database.BaseIdentifiable;
023 import org.sonar.api.database.DatabaseProperties;
024
025 import javax.persistence.Column;
026 import javax.persistence.Entity;
027 import javax.persistence.Lob;
028 import javax.persistence.Table;
029
030 @Entity
031 @Table(name = "snapshot_sources")
032 public class SnapshotSource extends BaseIdentifiable {
033
034 @Column(name = "snapshot_id")
035 private Integer snapshotId;
036
037 @Lob
038 @Column(name = "data", updatable = true, nullable = true, length = DatabaseProperties.MAX_TEXT_SIZE)
039 private String data;
040
041 public SnapshotSource() {
042 }
043
044 public SnapshotSource(Snapshot snapshot, String source) {
045 this.snapshotId = snapshot.getId();
046 this.data = source;
047 }
048
049 public SnapshotSource(Integer snapshotId, String source) {
050 this.snapshotId = snapshotId;
051 this.data = source;
052 }
053
054 public void setSnapshot(Snapshot snapshot) {
055 this.snapshotId = snapshot.getId();
056 }
057
058 public String getData() {
059 return data;
060 }
061
062 public void setData(String data) {
063 this.data = data;
064 }
065
066 @Override
067 public boolean equals(Object obj) {
068 if (!(obj instanceof SnapshotSource)) {
069 return false;
070 }
071 if (this == obj) {
072 return true;
073 }
074 SnapshotSource other = (SnapshotSource) obj;
075 return snapshotId.equals(other.snapshotId);
076 }
077
078 @Override
079 public int hashCode() {
080 return snapshotId.hashCode();
081 }
082 }