001 package com.bea.medrec.entities;
002
003 import com.bea.medrec.value.Patient;
004 import com.bea.medrec.value.User;
005 import javax.ejb.CreateException;
006 import weblogic.ejb.GenericEntityBean;
007 import weblogic.ejbgen.*;
008
009 /**
010 * <p>UserEJB is a Container Managed EntityBean that
011 * manipulates user persisted data.</p>
012 *
013 * @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
014 */
015 @CreateDefaultDbmsTables(value = "Disabled")
016 @EjbLocalRefs({
017 @EjbLocalRef(name = "ejb/local/patient",
018 home = "com.bea.medrec.entities.PatientLocalHome",
019 local = "com.bea.medrec.entities.PatientLocal",
020 type = Constants.RefType.ENTITY,
021 link = "PatientEJB")
022 })
023 @Entity(maxBeansInCache = "1000",
024 dataSourceName = "jdbc/MedRecTxDataSource",
025 transTimeoutSeconds = "0",
026 ejbName = "UserEJB",
027 reentrant = Constants.Bool.FALSE,
028 concurrencyStrategy = Constants.ConcurrencyStrategy.DATABASE,
029 delayDatabaseInsertUntil = Entity.DelayDatabaseInsertUntil.EJB_POST_CREATE,
030 tableName = "medrec_user",
031 readTimeoutSeconds = "600",
032 primKeyClass = "java.lang.String",
033 defaultTransaction = Constants.TransactionAttribute.MANDATORY,
034 abstractSchemaName = "UserEJB")
035 @FileGeneration(localClass = Constants.Bool.TRUE,
036 localHome = Constants.Bool.TRUE,
037 valueClass = Constants.Bool.FALSE)
038 @Finders({
039 @Finder(signature = "java.util.Collection<UserLocal> findByStatus(java.lang.String n0)",
040 ejbQl = "SELECT OBJECT(o) FROM UserEJB AS o WHERE o.status = ?1"),
041 @Finder(signature = "com.bea.medrec.entities.UserLocal findByUsername(java.lang.String n0)",
042 ejbQl = "SELECT OBJECT(o) FROM UserEJB AS o WHERE o.username = ?1")
043 })
044 @Relations({
045 @Relation(cascadeDelete = Constants.Bool.FALSE,
046 cmrField = "patient",
047 name = "User-Patient",
048 roleName = "User-Has-Patient",
049 multiplicity = Relation.Multiplicity.ONE,
050 targetEjb = "PatientEJB")
051 })
052 public abstract class UserEJB extends GenericEntityBean {
053
054 // Local methods
055 // Container managed fields
056 @CmpField(column = "username",
057 orderingNumber = "1")
058 @LocalMethod()
059 @PrimkeyField()
060 public abstract String getUsername();
061
062 @LocalMethod()
063 public abstract void setUsername(String email);
064
065 @CmpField(column = "password",
066 orderingNumber = "2")
067 @LocalMethod()
068 public abstract String getPassword();
069
070 @LocalMethod()
071 public abstract void setPassword(String password);
072
073 @CmpField(column = "status",
074 orderingNumber = "3")
075 @LocalMethod()
076 public abstract String getStatus();
077
078 @LocalMethod()
079 public abstract void setStatus(String status);
080
081 // Container manager methods
082 @CmrField(orderingNumber = "4")
083 @LocalMethod()
084 public abstract PatientLocal getPatient();
085
086 @LocalMethod()
087 public abstract void setPatient(PatientLocal patient);
088
089 /**
090 * <p>Returns associated patient object.</p>
091 */
092 @LocalMethod()
093 public Patient getPatientObj() {
094 return getPatient().getPatientLite();
095 }
096
097 /**
098 * <p>Returns a value object representation of the bean.</p>
099 *
100 * @return User
101 */
102 @LocalMethod()
103 public User getUser() {
104 User user = new User();
105 user.setUsername(getUsername());
106 user.setPassword(getPassword());
107 user.setStatus(getStatus());
108 return user;
109 }
110
111 // Home methods
112 /**
113 * <p>User create.</p>
114 */
115 public Object ejbCreate(String pUsername,
116 String pPassword,
117 String pStatus) throws CreateException {
118 setUsername(pUsername);
119 setPassword(pPassword);
120 setStatus(pStatus);
121 return null;
122 }
123
124 public void ejbPostCreate(String pUsername,
125 String pPassword,
126 String pStatus) throws CreateException {
127 /* not implemented */
128 }
129
130 /**
131 * <p>User methods.</p>
132 */
133 public Object ejbCreate(User user) throws CreateException {
134 setUsername(user.getUsername());
135 setPassword(user.getEncodedPassword());
136 setStatus(user.getStatus());
137 return null;
138 }
139
140 public void ejbPostCreate(User user) throws CreateException {
141 /* not implemented */
142 }
143 }
|