1 3 package org.objectweb.jonas.jtests.beans.relation.rcycle; 4 5 import java.util.ArrayList ; 6 import java.util.Collection ; 7 import java.util.Iterator ; 8 9 import javax.ejb.FinderException ; 10 11 import org.objectweb.jonas.common.Log; 12 import org.objectweb.util.monolog.api.BasicLevel; 13 import org.objectweb.util.monolog.api.Logger; 14 15 16 30 public abstract class PersonEC2 implements javax.ejb.EntityBean { 31 32 private static Logger logger = null; 33 private javax.ejb.EntityContext ejbContext; 34 private PersonHomeLocal plHome = null; 35 36 37 41 public abstract Integer getId(); 42 public abstract void setId(Integer id); 43 44 public abstract String getName(); 45 public abstract void setName(String name); 46 47 public abstract int getSex(); 48 public abstract void setSex(int sex); 49 50 public abstract PersonLocal getSpouse(); 51 public abstract void setSpouse(PersonLocal spouse); 52 53 public abstract Collection getParents(); 54 public abstract void setParents(Collection parents); 55 56 public abstract Collection getChildren(); 57 public abstract void setChildren(Collection parents); 58 59 public abstract PersonLocal getGuardian(); 60 public abstract void setGuardian(PersonLocal guardian); 61 62 public abstract Collection getGuardianOf(); 63 public abstract void setGuardianOf(Collection guardianOf); 64 65 66 70 public java.lang.String ejbCreate(Integer id, String name, int sex) 71 throws javax.ejb.CreateException { 72 logger.log(BasicLevel.DEBUG, "id = " + id + ", name = " + name + ", sex = " + sex); 73 setId(id); 75 setName(name); 76 setSex(sex); 77 return null; 78 } 79 80 public void ejbPostCreate(Integer id, String name, int sex) { 81 logger.log(BasicLevel.DEBUG, ""); 82 } 83 84 public Integer retrieveSpouse() { 85 PersonLocal spouse = getSpouse(); 86 if (spouse == null) { 87 logger.log(BasicLevel.DEBUG, "return null"); 88 return null; 89 } else { 90 logger.log(BasicLevel.DEBUG, "return " + spouse.getId()); 91 return spouse.getId(); 92 } 93 } 94 95 public void assignSpouse(Integer id) throws FinderException { 96 logger.log(BasicLevel.DEBUG, "param=" + id); 97 if (id != null) { 98 PersonLocal spouse = plHome.findByPrimaryKey(id); 99 setSpouse(spouse); 100 } else { 101 setSpouse(null); 102 } 103 } 104 105 public Collection retrieveParents() { 106 Collection ps = getParents(); 107 ArrayList result; 108 if (ps.size() <= 0) { 109 result = new ArrayList (); 110 } else { 111 result = new ArrayList (ps.size()); 112 } 113 for (Iterator it = ps.iterator(); it.hasNext();) { 114 result.add(((PersonLocal) it.next()).getPrimaryKey()); 115 } 116 logger.log(BasicLevel.DEBUG, "return=" + result); 117 return result; 118 } 119 120 public void assignParents(Collection c) throws FinderException { 121 logger.log(BasicLevel.DEBUG, "param=" + c); 122 ArrayList al; 123 if (c == null) { 124 al = new ArrayList (); 125 } else { 126 if (c.size() <= 0) { 127 al = new ArrayList (); 128 } else { 129 al = new ArrayList (c.size()); 130 for (Iterator it = c.iterator(); it.hasNext();) { 131 al.add(plHome.findByPrimaryKey((Integer ) it.next())); 132 } 133 } 134 } 135 setParents(al); 136 } 137 138 public void addInParents(Integer id) throws FinderException { 139 logger.log(BasicLevel.DEBUG, "param=" + id); 140 getParents().add(plHome.findByPrimaryKey(id)); 141 } 142 143 public Collection retrieveChildren() { 144 Collection ps = getChildren(); 145 ArrayList result; 146 if (ps.size() <= 0) { 147 result = new ArrayList (); 148 } else { 149 result = new ArrayList (ps.size()); 150 } 151 for (Iterator it = ps.iterator(); it.hasNext();) { 152 result.add(((PersonLocal) it.next()).getPrimaryKey()); 153 } 154 logger.log(BasicLevel.DEBUG, "return=" + result); 155 return result; 156 } 157 158 public Collection retrieveChildrenNames() { 159 Collection ps = getChildren(); 160 ArrayList result; 161 if (ps.size() <= 0) { 162 result = new ArrayList (); 163 } else { 164 result = new ArrayList (ps.size()); 165 } 166 for (Iterator it = ps.iterator(); it.hasNext();) { 167 result.add(((PersonLocal) it.next()).getName()); 168 } 169 logger.log(BasicLevel.DEBUG, "return=" + result); 170 return result; 171 } 172 173 public void assignChildren(Collection c) throws FinderException { 174 logger.log(BasicLevel.DEBUG, "param=" + c); 175 ArrayList al; 176 if (c == null) { 177 al = new ArrayList (); 178 } else { 179 if (c.size() <= 0) { 180 al = new ArrayList (); 181 } else { 182 al = new ArrayList (c.size()); 183 for (Iterator it = c.iterator(); it.hasNext();) { 184 al.add(plHome.findByPrimaryKey((Integer ) it.next())); 185 } 186 } 187 } 188 setChildren(al); 189 } 190 191 public void addInChildren(Integer id) throws FinderException { 192 logger.log(BasicLevel.DEBUG, "param=" + id); 193 getChildren().add(plHome.findByPrimaryKey(id)); 194 } 195 196 197 public Integer retrieveGuardian() { 198 PersonLocal guardian = getGuardian(); 199 if (guardian == null) { 200 logger.log(BasicLevel.DEBUG, "return null"); 201 return null; 202 } else { 203 logger.log(BasicLevel.DEBUG, "return " + guardian.getId()); 204 return guardian.getId(); 205 } 206 } 207 208 public void assignGuardian(Integer id) throws FinderException { 209 logger.log(BasicLevel.DEBUG, "param=" + id); 210 if (id != null) { 211 PersonLocal guardian = plHome.findByPrimaryKey(id); 212 setGuardian(guardian); 213 } else { 214 setGuardian(null); 215 } 216 } 217 218 public Collection retrieveGuardianOf() { 219 Collection ps = getGuardianOf(); 220 ArrayList result; 221 if (ps.size() <= 0) { 222 result = new ArrayList (); 223 } else { 224 result = new ArrayList (ps.size()); 225 } 226 for (Iterator it = ps.iterator(); it.hasNext();) { 227 result.add(((PersonLocal) it.next()).getPrimaryKey()); 228 } 229 logger.log(BasicLevel.DEBUG, "return=" + result); 230 return result; 231 } 232 233 public void assignInGuardianOf(Collection c) throws FinderException { 234 logger.log(BasicLevel.DEBUG, "param=" + c); 235 ArrayList al; 236 if (c == null) { 237 al = new ArrayList (); 238 } else { 239 if (c.size() <= 0) { 240 al = new ArrayList (); 241 } else { 242 al = new ArrayList (c.size()); 243 for (Iterator it = c.iterator(); it.hasNext();) { 244 al.add(plHome.findByPrimaryKey((Integer ) it.next())); 245 } 246 } 247 } 248 setGuardianOf(al); 249 } 250 251 public void addInGuardianOf(Integer id) throws FinderException { 252 logger.log(BasicLevel.DEBUG, "param=" + id); 253 getGuardianOf().add(plHome.findByPrimaryKey(id)); 254 } 255 256 public boolean testCmrNull() throws FinderException { 257 PersonLocal g = plHome.findByPrimaryKey(new Integer (3)); 258 PersonLocal sg = g.getSpouse(); 259 if (sg == null) { 260 return true; 261 } else { 262 return false; 263 } 264 } 265 266 270 public void setEntityContext(javax.ejb.EntityContext ctx) { 271 if (logger == null) { 273 logger = Log.getLogger("org.objectweb.jonas_tests"); 274 } 275 logger.log(BasicLevel.DEBUG, ""); 276 ejbContext = ctx; 278 plHome = (PersonHomeLocal) ejbContext.getEJBLocalHome(); 280 } 281 282 public void unsetEntityContext() { 283 logger.log(BasicLevel.DEBUG, ""); 284 ejbContext = null; 285 } 286 287 public void ejbRemove() throws javax.ejb.RemoveException { 288 logger.log(BasicLevel.DEBUG, ""); 289 } 290 291 292 public void ejbLoad() { 293 logger.log(BasicLevel.DEBUG, ""); 294 } 295 296 297 public void ejbStore() { 298 logger.log(BasicLevel.DEBUG, ""); 299 } 300 301 302 public void ejbPassivate() { 303 logger.log(BasicLevel.DEBUG, ""); 304 } 305 306 307 public void ejbActivate() { 308 logger.log(BasicLevel.DEBUG, ""); 309 } 310 311 } 312 313 314 315 | Popular Tags |