1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.imca.model;
17
18 import java.util.Date;
19
20 import net.sf.imca.model.entities.MembershipEntity;
21
22
23
24
25
26
27
28 public class MembershipBO {
29
30 public static final String STATUS_UNPAID = "not paid";
31 public static final String STATUS_ACTIVE = "active";
32 public static final String STATUS_EXPIRED = "expired";
33 public static final String STATUS_FUTURE = "future";
34
35
36
37
38
39
40 public MembershipBO(MembershipEntity entity){
41 this.setEntity(entity);
42 }
43
44
45
46
47 private MembershipEntity entity;
48
49
50
51
52
53
54 public MembershipEntity getEntity() {
55 return entity;
56 }
57
58
59
60
61
62
63 public void setEntity(MembershipEntity entity) {
64 this.entity = entity;
65 }
66
67 public String getStatus(){
68 if (getEntity().getPaid()){
69 Date now = new Date();
70 if (now.before(getEntity().getType().getValidFrom())) {
71 return STATUS_FUTURE;
72 } else if (now.after(getEntity().getType().getValidTo())) {
73 return STATUS_EXPIRED;
74 } else {
75 return STATUS_ACTIVE;
76 }
77 } else {
78 return STATUS_UNPAID;
79 }
80 }
81
82 }