1 package com.genimen.djeneric.test.strong.impl; 2 3 import com.genimen.djeneric.repository.DjAssociation; 4 import com.genimen.djeneric.repository.DjExtent; 5 import com.genimen.djeneric.repository.DjList; 6 import com.genimen.djeneric.repository.DjQueryByExample; 7 import com.genimen.djeneric.repository.DjSession; 8 import com.genimen.djeneric.repository.exceptions.DjenericException; 9 import com.genimen.djeneric.test.strong.Orderline; 10 import com.genimen.djeneric.test.strong.OrderlineCursor; 11 import com.genimen.djeneric.test.strong.OrderlineQbe; 12 import com.genimen.djeneric.test.strong.Product; 13 import com.genimen.djeneric.test.strong.TestException; 14 15 public class ProductImpl extends TestObjectImpl implements Product 19 { 20 private static boolean propidx_set = false; 21 private static int PROPIDX_ID; 22 private static int PROPIDX_PRODUCTNUMBER; 23 private static int PROPIDX_NAME; 24 private static int PROPIDX_DESCRIPTION; 25 26 protected ProductImpl(DjSession session, DjExtent extent) throws DjenericException 27 { 28 super(session, extent); 29 if (!propidx_set) 30 { 31 propidx_set = true; 32 PROPIDX_ID = extent.getPropertyIndex("id"); 33 PROPIDX_PRODUCTNUMBER = extent.getPropertyIndex("productNumber"); 34 PROPIDX_NAME = extent.getPropertyIndex("name"); 35 PROPIDX_DESCRIPTION = extent.getPropertyIndex("description"); 36 } 37 } 38 39 public long determineObjectId() throws TestException 40 { 41 try 42 { 43 return getObjectId(); 44 } 45 catch (Exception x) 46 { 47 throw new TestException(x); 48 } 49 } 50 51 public long getId() 52 { 53 return getLong(PROPIDX_ID); 54 } 55 56 public boolean isNullId() 57 { 58 return isNull(PROPIDX_ID); 59 } 60 61 public int getProductNumber() 62 { 63 return getInt(PROPIDX_PRODUCTNUMBER); 64 } 65 66 public boolean isNullProductNumber() 67 { 68 return isNull(PROPIDX_PRODUCTNUMBER); 69 } 70 71 public void setProductNumber(int value) throws TestException 72 { 73 try 74 { 75 setInt(PROPIDX_PRODUCTNUMBER, value); 76 } 77 catch (Exception x) 78 { 79 throw new TestException(x); 80 } 81 } 82 83 public void setNullProductNumber() throws TestException 84 { 85 try 86 { 87 setNull(PROPIDX_PRODUCTNUMBER); 88 } 89 catch (Exception x) 90 { 91 throw new TestException(x); 92 } 93 } 94 95 public String getName() 96 { 97 return getString(PROPIDX_NAME); 98 } 99 100 public boolean isNullName() 101 { 102 return isNull(PROPIDX_NAME); 103 } 104 105 public void setName(String value) throws TestException 106 { 107 try 108 { 109 setString(PROPIDX_NAME, value); 110 } 111 catch (Exception x) 112 { 113 throw new TestException(x); 114 } 115 } 116 117 public void setNullName() throws TestException 118 { 119 try 120 { 121 setNull(PROPIDX_NAME); 122 } 123 catch (Exception x) 124 { 125 throw new TestException(x); 126 } 127 } 128 129 public byte[] getDescription() 130 { 131 return getBytes(PROPIDX_DESCRIPTION); 132 } 133 134 public boolean isNullDescription() 135 { 136 return isNull(PROPIDX_DESCRIPTION); 137 } 138 139 public void setDescription(byte[] value) throws TestException 140 { 141 try 142 { 143 setBytes(PROPIDX_DESCRIPTION, value); 144 } 145 catch (Exception x) 146 { 147 throw new TestException(x); 148 } 149 } 150 151 public void setNullDescription() throws TestException 152 { 153 try 154 { 155 setNull(PROPIDX_DESCRIPTION); 156 } 157 catch (Exception x) 158 { 159 throw new TestException(x); 160 } 161 } 162 163 165 public Orderline[] getOrderlines() throws TestException 166 { 167 return getOrderlines(null); 168 } 169 170 public Orderline[] getOrderlines(OrderlineQbe qbeItf) throws TestException 171 { 172 try 173 { 174 DjList result; 175 DjQueryByExample qbe = (DjQueryByExample) qbeItf; 176 if (qbe == null) result = getDetailAssociationByName("orderlines").getObjects(); 177 else result = getDetailAssociationByName("orderlines").getObjects(qbe, false); 178 result.sort(getExtent()); 179 return (Orderline[]) result.toArray(new Orderline[0]); 180 } 181 catch (Exception x) 182 { 183 throw new TestException(x); 184 } 185 } 186 187 public OrderlineCursor getOrderlinesCursor(OrderlineQbe qbeItf) throws TestException 188 { 189 try 190 { 191 DjQueryByExample qbe = (DjQueryByExample) qbeItf; 192 return new OrderlineCursorImpl(getDetailAssociationByName("orderlines").getObjectsCursor(qbe, false)); 193 } 194 catch (Exception x) 195 { 196 throw new TestException(x); 197 } 198 } 199 200 public OrderlineCursor getOrderlinesCursor() throws TestException 201 { 202 try 203 { 204 return new OrderlineCursorImpl(getDetailAssociationByName("orderlines").getObjectsCursor(false)); 205 } 206 catch (Exception x) 207 { 208 throw new TestException(x); 209 } 210 } 211 212 public void addToOrderlines(Orderline orderlines) throws TestException 213 { 214 try 215 { 216 orderlines.setProduct(this); 217 DjAssociation assoc = getDetailAssociationByName("orderlines"); 218 if (assoc.isDetailsLoaded()) assoc.getObjects().add(orderlines); 219 } 220 catch (Exception x) 221 { 222 throw new TestException(x); 223 } 224 } 225 226 public Orderline createOrderlineInOrderlines() throws TestException 227 { 228 try 229 { 230 TestSessionImpl ses = (TestSessionImpl) getSession(); 231 Orderline obj = ses.createOrderline(); 232 addToOrderlines(obj); 233 return obj; 234 } 235 catch (Exception x) 236 { 237 throw new TestException(x); 238 } 239 } 240 241 } | Popular Tags |