001package org.apache.fulcrum.security.torque.om; 002 003import java.sql.ResultSet; 004import java.sql.SQLException; 005import java.util.List; 006 007import org.apache.commons.logging.Log; 008import org.apache.commons.logging.LogFactory; 009import org.apache.torque.Column; 010import org.apache.torque.TorqueException; 011import org.apache.torque.criteria.Criteria; 012import org.apache.torque.om.mapper.RecordMapper; 013 014 015/** 016 * Maps ResultSet rows into TorqueTurbineUser objects. 017 * 018 * The skeleton for this class was autogenerated by Torque on: 019 * 020 * [Thu Nov 04 13:34:23 CET 2021] 021 * 022 */ 023@SuppressWarnings("unused") 024public class BaseTorqueTurbineUserRecordMapper implements RecordMapper<TorqueTurbineUser> 025{ 026 /** Serial version */ 027 private static final long serialVersionUID = 1636029263832L; 028 029 /** The class log. */ 030 private static Log log 031 = LogFactory.getLog(BaseTorqueTurbineUserRecordMapper.class); 032 033 /** 034 * Constructs the object from the current row in the resultSet. 035 * 036 * @param resultSet the resultSet to operate on, already pointing 037 * to the correct row. Not null. 038 * @param offset a possible offset in the columns to be considered 039 * (if previous columns contain other objects), 040 * or 0 for no offset. 041 * @param criteria The criteria which created the result set. 042 * If set, the attributes to set in the data object 043 * are determined from the select columns in the criteria; 044 * if no matching column can be found, null is returned. 045 * If not set, all of the table's columns are read from the 046 * result set in the order defined in the table definition. 047 * 048 * @return the mapped object, not null. 049 * 050 * @throws TorqueException when reading fields from the RecordSet fails 051 * or if a Criteria is passed which contains select columns other 052 * than the columns in the FULCRUM_TURBINE_USER table. 053 */ 054 public TorqueTurbineUser processRow( 055 ResultSet resultSet, 056 int offset, 057 Criteria criteria) 058 throws TorqueException 059 { 060 TorqueTurbineUser torqueTurbineUser = new TorqueTurbineUser(); 061 062 try 063 { 064 torqueTurbineUser.setLoading(true); 065 if (criteria == null) 066 { 067 torqueTurbineUser.setEntityId( 068 getEntityId(resultSet, offset + 1)); 069 torqueTurbineUser.setEntityName( 070 getEntityName(resultSet, offset + 2)); 071 torqueTurbineUser.setPassword( 072 getPassword(resultSet, offset + 3)); 073 torqueTurbineUser.setFirstName( 074 getFirstName(resultSet, offset + 4)); 075 torqueTurbineUser.setLastName( 076 getLastName(resultSet, offset + 5)); 077 torqueTurbineUser.setEmail( 078 getEmail(resultSet, offset + 6)); 079 torqueTurbineUser.setObjectdata( 080 getObjectdata(resultSet, offset + 7)); 081 } 082 else 083 { 084 // try to get columns to be mapped 085 // from criteria's select columns 086 boolean columnMapped = false; 087 int totalOffset = offset + 1; 088 List<Column> selectColumns = criteria.getSelectColumns(); 089 List<Column> columnsWithoutOffset = selectColumns.subList( 090 offset, 091 selectColumns.size()); 092 for (Column column : columnsWithoutOffset) 093 { 094 if (BaseTorqueTurbineUserPeer.USER_ID.getSqlExpression().equals( 095 column.getSqlExpression())) 096 { 097 torqueTurbineUser.setEntityId( 098 getEntityId(resultSet, totalOffset)); 099 columnMapped = true; 100 } 101 else if (BaseTorqueTurbineUserPeer.LOGIN_NAME.getSqlExpression().equals( 102 column.getSqlExpression())) 103 { 104 torqueTurbineUser.setEntityName( 105 getEntityName(resultSet, totalOffset)); 106 columnMapped = true; 107 } 108 else if (BaseTorqueTurbineUserPeer.PASSWORD_VALUE.getSqlExpression().equals( 109 column.getSqlExpression())) 110 { 111 torqueTurbineUser.setPassword( 112 getPassword(resultSet, totalOffset)); 113 columnMapped = true; 114 } 115 else if (BaseTorqueTurbineUserPeer.FIRST_NAME.getSqlExpression().equals( 116 column.getSqlExpression())) 117 { 118 torqueTurbineUser.setFirstName( 119 getFirstName(resultSet, totalOffset)); 120 columnMapped = true; 121 } 122 else if (BaseTorqueTurbineUserPeer.LAST_NAME.getSqlExpression().equals( 123 column.getSqlExpression())) 124 { 125 torqueTurbineUser.setLastName( 126 getLastName(resultSet, totalOffset)); 127 columnMapped = true; 128 } 129 else if (BaseTorqueTurbineUserPeer.EMAIL.getSqlExpression().equals( 130 column.getSqlExpression())) 131 { 132 torqueTurbineUser.setEmail( 133 getEmail(resultSet, totalOffset)); 134 columnMapped = true; 135 } 136 else if (BaseTorqueTurbineUserPeer.OBJECTDATA.getSqlExpression().equals( 137 column.getSqlExpression())) 138 { 139 torqueTurbineUser.setObjectdata( 140 getObjectdata(resultSet, totalOffset)); 141 columnMapped = true; 142 } 143 totalOffset++; 144 } 145 if (!columnMapped) 146 { 147 log.debug("no columns to map found in criteria, " 148 + "returning null"); 149 return null; 150 } 151 } 152 torqueTurbineUser.setNew(false); 153 torqueTurbineUser.setModified(false); 154 } 155 finally 156 { 157 torqueTurbineUser.setLoading(false); 158 } 159 return torqueTurbineUser; 160 } 161 162 /** 163 * Reads the value of the <code>columnIndex</code>'th column 164 * in the <code>resultSet</code> so that it can be used to set 165 * the field entityId in TorqueTurbineUser. 166 * 167 * @param resultSet the ResultSet to read from, not null. 168 * @param columnIndex the index in the resultSet which should be read. 169 * 170 * @return the content of the column. 171 * 172 * @throws SQLException if a problem occurs when reading 173 * from the resultSet. 174 */ 175 protected Integer getEntityId( 176 ResultSet resultSet, 177 int columnIndex) 178 throws TorqueException 179 { 180 try 181 { 182 Integer value = resultSet.getInt(columnIndex); 183 if (resultSet.wasNull()) 184 { 185 value = null; 186 } 187 return value; 188 } 189 catch (SQLException e) 190 { 191 throw new TorqueException(e); 192 } 193 } 194 /** 195 * Reads the value of the <code>columnIndex</code>'th column 196 * in the <code>resultSet</code> so that it can be used to set 197 * the field entityName in TorqueTurbineUser. 198 * 199 * @param resultSet the ResultSet to read from, not null. 200 * @param columnIndex the index in the resultSet which should be read. 201 * 202 * @return the content of the column. 203 * 204 * @throws SQLException if a problem occurs when reading 205 * from the resultSet. 206 */ 207 protected String getEntityName( 208 ResultSet resultSet, 209 int columnIndex) 210 throws TorqueException 211 { 212 try 213 { 214 return resultSet.getString(columnIndex); 215 } 216 catch (SQLException e) 217 { 218 throw new TorqueException(e); 219 } 220 } 221 /** 222 * Reads the value of the <code>columnIndex</code>'th column 223 * in the <code>resultSet</code> so that it can be used to set 224 * the field password in TorqueTurbineUser. 225 * 226 * @param resultSet the ResultSet to read from, not null. 227 * @param columnIndex the index in the resultSet which should be read. 228 * 229 * @return the content of the column. 230 * 231 * @throws SQLException if a problem occurs when reading 232 * from the resultSet. 233 */ 234 protected String getPassword( 235 ResultSet resultSet, 236 int columnIndex) 237 throws TorqueException 238 { 239 try 240 { 241 return resultSet.getString(columnIndex); 242 } 243 catch (SQLException e) 244 { 245 throw new TorqueException(e); 246 } 247 } 248 /** 249 * Reads the value of the <code>columnIndex</code>'th column 250 * in the <code>resultSet</code> so that it can be used to set 251 * the field firstName in TorqueTurbineUser. 252 * 253 * @param resultSet the ResultSet to read from, not null. 254 * @param columnIndex the index in the resultSet which should be read. 255 * 256 * @return the content of the column. 257 * 258 * @throws SQLException if a problem occurs when reading 259 * from the resultSet. 260 */ 261 protected String getFirstName( 262 ResultSet resultSet, 263 int columnIndex) 264 throws TorqueException 265 { 266 try 267 { 268 return resultSet.getString(columnIndex); 269 } 270 catch (SQLException e) 271 { 272 throw new TorqueException(e); 273 } 274 } 275 /** 276 * Reads the value of the <code>columnIndex</code>'th column 277 * in the <code>resultSet</code> so that it can be used to set 278 * the field lastName in TorqueTurbineUser. 279 * 280 * @param resultSet the ResultSet to read from, not null. 281 * @param columnIndex the index in the resultSet which should be read. 282 * 283 * @return the content of the column. 284 * 285 * @throws SQLException if a problem occurs when reading 286 * from the resultSet. 287 */ 288 protected String getLastName( 289 ResultSet resultSet, 290 int columnIndex) 291 throws TorqueException 292 { 293 try 294 { 295 return resultSet.getString(columnIndex); 296 } 297 catch (SQLException e) 298 { 299 throw new TorqueException(e); 300 } 301 } 302 /** 303 * Reads the value of the <code>columnIndex</code>'th column 304 * in the <code>resultSet</code> so that it can be used to set 305 * the field email in TorqueTurbineUser. 306 * 307 * @param resultSet the ResultSet to read from, not null. 308 * @param columnIndex the index in the resultSet which should be read. 309 * 310 * @return the content of the column. 311 * 312 * @throws SQLException if a problem occurs when reading 313 * from the resultSet. 314 */ 315 protected String getEmail( 316 ResultSet resultSet, 317 int columnIndex) 318 throws TorqueException 319 { 320 try 321 { 322 return resultSet.getString(columnIndex); 323 } 324 catch (SQLException e) 325 { 326 throw new TorqueException(e); 327 } 328 } 329 /** 330 * Reads the value of the <code>columnIndex</code>'th column 331 * in the <code>resultSet</code> so that it can be used to set 332 * the field objectdata in TorqueTurbineUser. 333 * 334 * @param resultSet the ResultSet to read from, not null. 335 * @param columnIndex the index in the resultSet which should be read. 336 * 337 * @return the content of the column. 338 * 339 * @throws SQLException if a problem occurs when reading 340 * from the resultSet. 341 */ 342 protected byte[] getObjectdata( 343 ResultSet resultSet, 344 int columnIndex) 345 throws TorqueException 346 { 347 try 348 { 349 byte[] value = resultSet.getBytes(columnIndex); 350 if (resultSet.wasNull()) 351 { 352 value = null; 353 } 354 return value; 355 } 356 catch (SQLException e) 357 { 358 throw new TorqueException(e); 359 } 360 } 361 362}