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 = "FoilBasicSearch",
36 query = "SELECT o FROM FoilEntity o WHERE type LIKE :search")
37 })
38 public class FoilEntity {
39
40 /**
41 * Object Identifier.
42 */
43 @Id
44 @GeneratedValue(strategy=GenerationType.TABLE)
45 private long id;
46
47 /**
48 * The builders version type name for the equipment.
49 */
50 private String type = "";
51
52 /**
53 * Long description of the foils.
54 */
55 private String description = "";
56
57 @OneToOne
58 private EquipmentSupplierEntity builder;
59
60 public EquipmentSupplierEntity getBuilder() {
61 return builder;
62 }
63
64 public void setBuilder(EquipmentSupplierEntity builder) {
65 this.builder = builder;
66 }
67
68 public String getDescription() {
69 return description;
70 }
71
72 public void setDescription(String description) {
73 this.description = description;
74 }
75
76 public long getId() {
77 return id;
78 }
79
80 public void setId(long id) {
81 this.id = id;
82 }
83
84 public String getType() {
85 return type;
86 }
87
88 public void setType(String type) {
89 this.type = type;
90 }
91
92 /**
93 * Override the Object method to give a usable human readable
94 * representation of the Object.
95 */
96 public String toString(){
97 StringBuffer buf = new StringBuffer();
98 buf.append(builder.toString());
99 if (type.length() > 0) {
100 buf.append(" " + type);
101 }
102 buf.append(" (" + id + ")");
103 return buf.toString();
104 }
105
106 }