1
2 package com.pnpconsult.zeiterfassung.model;
3
4 import java.util.Set;
5
6 import com.pnpconsult.zeiterfassung.util.Description;
7 import com.pnpconsult.zeiterfassung.util.NumberUtils;
8
9 /***
10 * @author <a href="mailto:powerpete@users.sf.net">M. Petersen</a>
11 * @version $Id: Activity.java,v 1.10 2004/08/02 20:36:03 powerpete Exp $
12 *
13 * @hibernate.class table="activity"
14 */
15 public class Activity extends ArchivableObject
16 {
17 private long id = -1;
18 private String name;
19 private float billingFactor = 1.0F;
20 private Set userEntries;
21
22 /***
23 * @param activityId
24 */
25 public Activity(long id)
26 {
27 this.id = id;
28 }
29
30 public Activity()
31 {}
32
33 /***
34 * @return Returns the id.
35 *
36 * @hibernate.id generator-class="identity" unsaved-value="-1"
37 */
38 public long getId()
39 {
40 return id;
41 }
42
43 /***
44 * @param id The id to set.
45 */
46 public void setId(long id)
47 {
48 this.id = id;
49 }
50
51 /***
52 * @return Returns the billingFactor.
53 *
54 * @hibernate.property
55 */
56 public float getBillingFactor()
57 {
58 return billingFactor;
59 }
60
61 /***
62 * @param billingFactor The billingFactor to set.
63 */
64 public void setBillingFactor(float billingFactor)
65 {
66 this.billingFactor = billingFactor;
67 }
68
69 /***
70 * @return Returns the name.
71 *
72 * @hibernate.property
73 */
74 public String getName()
75 {
76 return name;
77 }
78
79 public String getNameWithBillingFactor()
80 {
81 StringBuffer sbuf = new StringBuffer();
82 sbuf.append(name);
83 if (billingFactor != 1.0D)
84 {
85 sbuf.append(" (Faktor: ");
86 sbuf.append(NumberUtils.formatShort(billingFactor));
87 sbuf.append(")");
88 }
89 return sbuf.toString();
90 }
91
92 /***
93 * @param name The name to set.
94 */
95 public void setName(String name)
96 {
97 this.name = name;
98 }
99
100 protected Description buildDescription()
101 {
102 return new Description().append(name);
103 }
104
105 /***
106 * @hibernate.set cascade="none"
107 * @hibernate.collection-key column="activityId"
108 * @hibernate.collection-one-to-many class="com.pnpconsult.zeiterfassung.model.UserEntry"
109 */
110 public Set getUserEntries()
111 {
112 return userEntries;
113 }
114
115 public void setUserEntries(Set userEntries)
116 {
117 this.userEntries = userEntries;
118 }
119 }