01: /*
02: * JOSSO: Java Open Single Sign-On
03: *
04: * Copyright 2004-2008, Atricore, Inc.
05: *
06: * This is free software; you can redistribute it and/or modify it
07: * under the terms of the GNU Lesser General Public License as
08: * published by the Free Software Foundation; either version 2.1 of
09: * the License, or (at your option) any later version.
10: *
11: * This software is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this software; if not, write to the Free
18: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20: *
21: * author Kurt T Stam
22: */
23: package org.josso.seam.console;
24:
25: import org.jboss.seam.annotations.In;
26: import org.jboss.seam.annotations.Name;
27: import org.jboss.seam.framework.EntityHome;
28:
29: @Name("userRoleHome")
30: public class UserRoleHome extends EntityHome<UserRole> {
31:
32: private static final long serialVersionUID = 1L;
33:
34: @In(create=true)
35: RoleHome roleHome;
36: @In(create=true)
37: UsernameHome usernameHome;
38:
39: public void setUserRoleId(Integer id) {
40: setId(id);
41: }
42:
43: public Integer getUserRoleId() {
44: return (Integer) getId();
45: }
46:
47: @Override
48: protected UserRole createInstance() {
49: UserRole userRole = new UserRole();
50: return userRole;
51: }
52:
53: public void wire() {
54: Role role = roleHome.getDefinedInstance();
55: if (role != null) {
56: getInstance().setRole(role);
57: }
58: Username username = usernameHome.getDefinedInstance();
59: if (username != null) {
60: getInstance().setUsername(username);
61: }
62: }
63:
64: public boolean isWired() {
65: if (getInstance().getRole() == null)
66: return false;
67: if (getInstance().getUsername() == null)
68: return false;
69: return true;
70: }
71:
72: public UserRole getDefinedInstance() {
73: return isIdDefined() ? getInstance() : null;
74: }
75:
76: }
|