01: package org.osbl.riskmanagement.gui;
02:
03: import org.conform.*;
04: import org.osbl.identity.model.Identity;
05: import org.osbl.identity.model.User;
06: import org.osbl.persistence.*;
07: import org.osbl.ServiceProvider;
08: import org.wings.session.SessionManager;
09:
10: /**
11: * @author hengels
12: * @version $Revision: 840 $
13: */
14: public class MePropertyData extends DefaultPropertyData {
15: private Identity identity;
16:
17: public MePropertyData(DefaultBeanData beanData,
18: PropertyMeta property) {
19: super (beanData, property);
20: }
21:
22: public Object getValue() {
23: return super .getValue() != null;
24: }
25:
26: public void setValue(Object value) {
27: if (Boolean.TRUE.equals(value)) {
28: super .setValue(getIdentity());
29: } else
30: super .setValue(null);
31: }
32:
33: private Identity getIdentity() {
34: if (identity == null) {
35: Persistence persistence = (Persistence) ServiceProvider
36: .getInstance().getService("IdentityPersistence");
37: SimpleQueryCommand command = (SimpleQueryCommand) persistence
38: .createCommand("list");
39: command.setType(User.class);
40: command.addFilter("account", Operator.EQUAL, SessionManager
41: .getSession().getServletRequest()
42: .getUserPrincipal().getName());
43: User user = (User) command.execute().get(0);
44: identity = user.getGeneral();
45: }
46: return identity;
47: }
48: }
|