View Javadoc

1   /*
2    * Copyright 2007 The International Moth Class Association (IMCA)
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.imca.model.entities;
17  
18  import java.util.Date;
19  
20  import javax.persistence.Entity;
21  import javax.persistence.GeneratedValue;
22  import javax.persistence.GenerationType;
23  import javax.persistence.Id;
24  import javax.persistence.NamedQueries;
25  import javax.persistence.NamedQuery;
26  import javax.persistence.OneToOne;
27  
28  /**
29   * An persistence entity description. There is no logic just getter and setters,
30   * for the properties. This Object represents a table in the database and the
31   * properties are fields.
32   *
33   * @author dougculnane
34   */
35  @Entity
36  @NamedQueries( {
37      @NamedQuery(name = "SailBasicSearch",
38              query="SELECT o FROM SailEntity o WHERE " +
39                      "o.description = :search")
40  })
41  public class SailEntity {
42  
43      /**
44       * Object Identifier.
45       */
46      @Id
47      @GeneratedValue(strategy=GenerationType.TABLE)
48      private long id;
49  
50      /**
51       * The sailmaker's version name for the sail.
52       */
53      private String type = "";
54  
55      /**
56       * Long description of the sail.
57       */
58      private String description = "";
59      
60      @OneToOne
61      private EquipmentSupplierEntity sailmaker;
62  
63      @OneToOne
64      private PersonEntity measurer;
65      
66      private Date measuredDate;
67  
68      public long getId() {
69          return id;
70      }
71  
72      public void setId(long id) {
73          this.id = id;
74      }
75  
76      public PersonEntity getMeasurer() {
77          return measurer;
78      }
79  
80      public void setMeasurer(PersonEntity measurer) {
81          this.measurer = measurer;
82      }
83  
84      public EquipmentSupplierEntity getSailmaker() {
85          return sailmaker;
86      }
87  
88      public void setSailmaker(EquipmentSupplierEntity sailmaker) {
89          this.sailmaker = sailmaker;
90      }
91  
92      public Date getMeasuredDate() {
93          return measuredDate;
94      }
95  
96      public void setMeasuredDate(Date measuredDate) {
97          this.measuredDate = measuredDate;
98      }
99      
100     public String getType() {
101         return type;
102     }
103 
104     public void setType(String type) {
105         this.type = type;
106     }
107 
108     public String getDescription() {
109         return description;
110     }
111 
112     public void setDescription(String description) {
113         this.description = description;
114     }
115 
116     /**
117      * Override the Object method to give a usable human readable 
118      * representation of the Object.
119      */
120     public String toString(){
121         StringBuffer buf = new StringBuffer();
122         buf.append(sailmaker.toString());
123         if (type.length() > 0) {
124             buf.append(" " + type);
125         }
126         buf.append(" (" + id + ")");
127         return buf.toString();
128     }
129 }