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 javax.persistence.Entity;
19  import javax.persistence.GeneratedValue;
20  import javax.persistence.GenerationType;
21  import javax.persistence.Id;
22  import javax.persistence.NamedQueries;
23  import javax.persistence.NamedQuery;
24  import javax.persistence.OneToOne;
25  
26  /**
27   * An persistence entity description. There is no logic just getter and setters,
28   * for the properties. This Object represents a table in the database and the
29   * properties are fields.
30   *
31   * @author dougculnane
32   */
33  @Entity
34  @NamedQueries( { 
35      @NamedQuery(name = "MastBasicSearch",
36              query = "SELECT m FROM MastEntity m WHERE " +
37              		"m.description LIKE :search")
38  })
39  public class MastEntity {
40  
41      /**
42       * Object Identifier.
43       */
44      @Id
45      @GeneratedValue(strategy=GenerationType.TABLE)
46      private long id;
47  
48      /**
49       * The builders version type name for the equipment.
50       */
51      private String type = "";
52  
53      /**
54       * Long description of the mast.
55       */
56      private String description = "";
57      
58  
59      @OneToOne
60      private EquipmentSupplierEntity builder;
61  
62      public EquipmentSupplierEntity getBuilder() {
63          return builder;
64      }
65  
66      public void setBuilder(EquipmentSupplierEntity builder) {
67          this.builder = builder;
68      }
69  
70      public String getDescription() {
71          return description;
72      }
73  
74      public void setDescription(String description) {
75          this.description = description;
76      }
77  
78      public long getId() {
79          return id;
80      }
81  
82      public void setId(long id) {
83          this.id = id;
84      }
85      
86      public String getType() {
87          return type;
88      }
89  
90      public void setType(String type) {
91          this.type = type;
92      }
93  
94      /**
95       * Override the Object method to give a usable human readable 
96       * representation of the Object.
97       */
98      public String toString(){
99          StringBuffer buf = new StringBuffer();
100         buf.append(builder.toString());
101         if (type.length() > 0) {
102             buf.append(" " + type);
103         }
104         buf.append(" (" + id + ")");
105         return buf.toString();
106     }
107 }