1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.imca.web.backingbeans;
17
18 import java.util.HashMap;
19 import java.util.HashSet;
20 import java.util.List;
21 import java.util.Vector;
22
23 import javax.faces.context.FacesContext;
24
25 import net.sf.imca.model.MembershipBO;
26 import net.sf.imca.model.PersonBO;
27 import net.sf.imca.model.entities.PersonEntity;
28 import net.sf.imca.model.exceptions.DataCheckingException;
29 import net.sf.imca.services.EditDataService;
30 import net.sf.imca.services.JoinImcaService;
31
32
33
34
35
36
37 public class MyDataBean {
38
39 private PersonEntity personEntity =
40 Utils.getWebUser().getPerson().getEntity();
41
42 private String password = "";
43
44 private String search = "";
45
46 private List<PersonBO> foundPeopleList = null;
47
48
49
50
51 private String userFeedbackMessage = "";
52
53 private String confirmPassword = "";
54
55
56 public void actionSave() {
57
58 EditDataService service = new EditDataService();
59 try {
60 service.saveMyData(personEntity, password, confirmPassword);
61 userFeedbackMessage = "Data Saved";
62 } catch (DataCheckingException e) {
63 userFeedbackMessage = e.getMessage();
64 }
65
66
67 FacesContext context = FacesContext.getCurrentInstance();
68 context.getViewRoot().setLocale(
69 Utils.getWebUser().getPerson().getLocale());
70 }
71
72
73 @SuppressWarnings("unchecked")
74 public void actionSearch() {
75
76 EditDataService service = new EditDataService();
77 List<PersonEntity> list = service.search("Person", search);
78
79 foundPeopleList = new Vector<PersonBO>();
80 for (int i=0; i < list.size(); i++) {
81 foundPeopleList.add(new PersonBO(list.get(i)));
82 }
83
84 userFeedbackMessage = "Found " + foundPeopleList.size() + " results";
85
86 }
87
88 public List<PersonBO> getFoundPeople() {
89 if (foundPeopleList == null) {
90 return new Vector<PersonBO>();
91 } else {
92 return foundPeopleList;
93 }
94 }
95
96 public String getPassword() {
97 return password;
98 }
99
100 public void setPassword(String password) {
101 this.password = password;
102 }
103
104 public String getUserFeedbackMessage() {
105 return userFeedbackMessage;
106 }
107
108 public void setUserFeedbackMessage(String userFeedbackMessage) {
109 this.userFeedbackMessage = userFeedbackMessage;
110 }
111
112 public String getConfirmPassword() {
113 return confirmPassword;
114 }
115
116 public void setConfirmPassword(String confirmPassword) {
117 this.confirmPassword = confirmPassword;
118 }
119
120 public PersonEntity getPersonEntity() {
121 return personEntity;
122 }
123
124 public void setPersonEntity(PersonEntity personEntity) {
125 this.personEntity = personEntity;
126 }
127
128 public MembershipBO[] getImcaMemberships(){
129 JoinImcaService service = new JoinImcaService();
130 return service.getImcaMemberships(Utils.getWebUser().getPerson());
131 }
132
133 public boolean getActiveMember(){
134 JoinImcaService service = new JoinImcaService();
135 return service.getActiveMember(Utils.getWebUser().getPerson());
136 }
137
138
139 public String getSearch() {
140 return search;
141 }
142
143
144 public void setSearch(String search) {
145 this.search = search;
146 }
147
148 }