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
024 import javax.persistence.*;
025
026 @Entity
027 @Table(name = "measure_data")
028 public class MeasureData extends BaseIdentifiable {
029
030 @OneToOne(fetch = FetchType.LAZY)
031 @JoinColumn(name = "measure_id")
032 private MeasureModel measure;
033
034 @Column(name = "snapshot_id", updatable = true, nullable = true)
035 private Integer snapshotId;
036
037 @Column(name = "data", updatable = true, nullable = true, length = 167772150)
038 private byte[] data;
039
040 public MeasureData(MeasureModel measure) {
041 this.measure = measure;
042 }
043
044 public MeasureData(MeasureModel measure, byte[] data) {
045 this.measure = measure;
046 this.data = data;
047 }
048
049 public MeasureData(MeasureModel measure, String dataString) {
050 this.measure = measure;
051 this.data = dataString.getBytes();
052 }
053
054 public MeasureData() {
055 }
056
057 public MeasureModel getMeasure() {
058 return measure;
059 }
060
061 public void setMeasure(MeasureModel measure) {
062 this.measure = measure;
063 }
064
065 public byte[] getData() {
066 return data;
067 }
068
069 public String getText() {
070 if (data != null) {
071 return new String(data);
072 }
073 return null;
074 }
075
076 public void setData(byte[] data) {
077 this.data = data;
078 }
079
080 public Integer getSnapshotId() {
081 return snapshotId;
082 }
083
084 public void setSnapshotId(Integer snapshotId) {
085 this.snapshotId = snapshotId;
086 }
087 }
088