1
2 package com.pnpconsult.zeiterfassung.model;
3
4 import java.util.SortedSet;
5 import java.util.TreeSet;
6
7 import com.pnpconsult.zeiterfassung.util.Description;
8
9 /***
10 * @author <a href="mailto:powerpete@users.sf.net">M. Petersen</a>
11 * @version $Id: Customer.java,v 1.8 2004/06/24 20:54:19 powerpete Exp $
12 *
13 * @hibernate.class table="customer"
14 */
15 public class Customer extends ArchivableObject
16 {
17 private long id = -1;
18 private String name;
19 private SortedSet projects = new TreeSet();
20
21 /***
22 * @return Returns the id.
23 *
24 * @hibernate.id generator-class="identity" unsaved-value="-1"
25 */
26 public long getId()
27 {
28 return id;
29 }
30
31 /***
32 * @param id The id to set.
33 */
34 public void setId(long id)
35 {
36 this.id = id;
37 }
38
39 /***
40 * @return Returns the name.
41 *
42 * @hibernate.property
43 */
44 public String getName()
45 {
46 return name;
47 }
48
49 /***
50 * @param name The name to set.
51 */
52 public void setName(String name)
53 {
54 this.name = name;
55 }
56
57 /***
58 * @return Returns the projects.
59 *
60 * @hibernate.set cascade="none" sort="natural" lazy="true"
61 * @hibernate.collection-key column="customerId"
62 * @hibernate.collection-one-to-many class="com.pnpconsult.zeiterfassung.model.Project"
63 */
64 public SortedSet getProjects()
65 {
66 return projects;
67 }
68
69 /***
70 * @param projects The projects to set.
71 */
72 public void setProjects(SortedSet projects)
73 {
74 this.projects = projects;
75 }
76
77 protected Description buildDescription()
78 {
79 return new Description().append(name);
80 }
81
82 public void addProject(Project project)
83 {
84 if (projects == null)
85 {
86 projects = new TreeSet();
87 }
88 projects.add(project);
89 }
90
91 }