00001 package cedar.hepdata.model;
00002
00003 import java.util.Set;
00004 import java.util.HashSet;
00005
00006 import cedar.hepdata.util.*;
00007
00008 import javax.persistence.*;
00009
00017 @Entity
00018 @Table(name="Observables")
00019 public class Observable extends Storeable {
00021 @Id @GeneratedValue
00022 @Column(name="OBSERVABLE_ID")
00023 private Long _id;
00024
00026 @Column(name="Name", nullable=false, unique=true)
00027 private String _name;
00028
00030 @Column(name="Description", nullable=false)
00031 private String _description = "";
00032
00034 @ManyToMany
00035 private Set<ObservableGroup> _observableGroups = new HashSet<ObservableGroup>();
00036
00038 @OneToMany(mappedBy="_observable")
00039 @org.hibernate.annotations.Cascade(value={org.hibernate.annotations.CascadeType.ALL})
00040 private Set<YAxis> _yAxes = new HashSet<YAxis>();
00041
00043 @Column(name="Unit", nullable=false)
00044 @org.hibernate.annotations.Type(type="cedar.hepdata.db.UnitUserType")
00045 private Unit _canonicalUnit = new Unit();
00046
00047
00049
00050
00052 public Observable() {}
00053
00055 public Observable(String name) {
00056 log().debug("Calling 1 arg constructor");
00057 setName(name);
00058 }
00059
00061 public Observable(String name, Unit unit) {
00062 this(name);
00063 log().debug("Calling 2 arg constructor");
00064 setCanonicalUnit(unit);
00065 }
00066
00067
00069
00070
00071
00072 public String getName() {
00073 return _name;
00074 }
00075 public Observable setName(String name) {
00076 _name = name;
00077 return this;
00078 }
00079
00080
00081
00082 public String getDescription() {
00083 return _description;
00084 }
00085 public Observable setDescription(String description) {
00086 _description = description;
00087 return this;
00088 }
00089
00090
00094 public Unit getCanonicalUnit() {
00095 return _canonicalUnit;
00096 }
00100 public Observable setCanonicalUnit(Unit canonicalUnit) {
00101 _canonicalUnit = canonicalUnit;
00102 return this;
00103 }
00104
00105
00106
00107 public Set<ObservableGroup> getObservableGroups() {
00108 return _observableGroups;
00109 }
00110 public Observable setObservableGroups(Set<ObservableGroup> observableGroups) {
00112 _observableGroups = observableGroups;
00113 return this;
00114 }
00115 public Observable addObservableGroup(ObservableGroup observableGroup) {
00116 if (observableGroup != null) {
00117 observableGroup.getObservables().add(this);
00118 _observableGroups.add(observableGroup);
00119 } else {
00120 log().warn("Tried to add a null ObservableGroup to an Observable");
00121 }
00122 return this;
00123 }
00124 public Observable removeObservableGroup(ObservableGroup observableGroup) {
00125 if (observableGroup != null) {
00126 observableGroup.getObservables().remove(this);
00127 _observableGroups.remove(observableGroup);
00128 } else {
00129 log().warn("Tried to remove a null ObservableGroup from an Observable");
00130 }
00131 return this;
00132 }
00133
00134
00135
00136 public Set<YAxis> getYAxes() {
00137 return _yAxes;
00138 }
00139 public Observable setYAxes(Set<YAxis> yAxes) {
00141 _yAxes = yAxes;
00142 return this;
00143 }
00144 public Observable addYAxis(YAxis yAxis) {
00145 if (yAxis != null) {
00146 _yAxes.add(yAxis);
00147 yAxis.setObservable(this);
00148 } else {
00149 log().warn("Tried to add a null YAxis to an Observable");
00150 }
00151 return this;
00152 }
00153 public Observable removeYAxis(YAxis yAxis) {
00154 if (yAxis != null) {
00155 _yAxes.remove(yAxis);
00156 yAxis.setObservable(null);
00157 } else {
00158 log().warn("Tried to remove a null YAxis from an Observable");
00159 }
00160 return this;
00161 }
00162
00163 }