BaseJobEntryTorqueRecordMapper.java
package org.apache.turbine.services.schedule;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.torque.Column;
import org.apache.torque.TorqueException;
import org.apache.torque.criteria.Criteria;
import org.apache.torque.om.mapper.RecordMapper;
import org.apache.torque.om.mapper.MappingStrategy;
/**
* Maps ResultSet rows into JobEntryTorque objects.
*
* The skeleton for this class was autogenerated by Torque on:
*
* [Tue Jun 17 14:08:22 CEST 2025]
*
*/
@SuppressWarnings("unused")
public class BaseJobEntryTorqueRecordMapper implements RecordMapper<JobEntryTorque>
{
/** Serial version */
private static final long serialVersionUID = 1750162102601L;
/** The class log. */
private static Log log
= LogFactory.getLog(BaseJobEntryTorqueRecordMapper.class);
private static final String JOB_ID_EXPRESSION = BaseJobEntryTorquePeer.JOB_ID.getSqlExpression();
private static final String SECOND_EXPRESSION = BaseJobEntryTorquePeer.SECOND.getSqlExpression();
private static final String MINUTE_EXPRESSION = BaseJobEntryTorquePeer.MINUTE.getSqlExpression();
private static final String HOUR_EXPRESSION = BaseJobEntryTorquePeer.HOUR.getSqlExpression();
private static final String WEEK_DAY_EXPRESSION = BaseJobEntryTorquePeer.WEEK_DAY.getSqlExpression();
private static final String DAY_OF_MONTH_EXPRESSION = BaseJobEntryTorquePeer.DAY_OF_MONTH.getSqlExpression();
private static final String TASK_EXPRESSION = BaseJobEntryTorquePeer.TASK.getSqlExpression();
private static final String EMAIL_EXPRESSION = BaseJobEntryTorquePeer.EMAIL.getSqlExpression();
private static final String PROPERTY_EXPRESSION = BaseJobEntryTorquePeer.PROPERTY.getSqlExpression();
private boolean useMappingStrategy = true;
private MappingStrategy<JobEntryTorque> strategy;
public void initStrategy()
{
this.strategy = new MappingStrategy<JobEntryTorque>();
}
/**
* Constructs the object from the current row in the resultSet.
*
* @param resultSet the resultSet to operate on, already pointing
* to the correct row. Not null.
* @param offset a possible offset in the columns to be considered
* (if previous columns contain other objects),
* or 0 for no offset.
* @param criteria The criteria which created the result set.
* If set, the attributes to set in the data object
* are determined from the select columns in the criteria;
* if no matching column can be found, null is returned.
* If not set, all of the table's columns are read from the
* result set in the order defined in the table definition.
*
* @return the mapped object, not null.
*
* @throws TorqueException when reading fields from the RecordSet fails
* or if a Criteria is passed which contains select columns other
* than the columns in the TURBINE_SCHEDULED_JOB table.
*/
public JobEntryTorque processRow(
ResultSet resultSet,
int offset,
Criteria criteria)
throws TorqueException
{
JobEntryTorque jobEntryTorque = new JobEntryTorque();
try
{
jobEntryTorque.setLoading(true);
if (criteria == null)
{
jobEntryTorque.setJobId(
getJobId(resultSet, offset + 1));
jobEntryTorque.setSecond(
getSecond(resultSet, offset + 2));
jobEntryTorque.setMinute(
getMinute(resultSet, offset + 3));
jobEntryTorque.setHour(
getHour(resultSet, offset + 4));
jobEntryTorque.setWeekDay(
getWeekDay(resultSet, offset + 5));
jobEntryTorque.setDayOfMonth(
getDayOfMonth(resultSet, offset + 6));
jobEntryTorque.setTask(
getTask(resultSet, offset + 7));
jobEntryTorque.setEmail(
getEmail(resultSet, offset + 8));
jobEntryTorque.setProperty(
getProperty(resultSet, offset + 9));
}
else
{
if (useMappingStrategy) {
initStrategy();
}
// try to get columns to be mapped
// from criteria's select columns
int totalOffset = offset + 1;
List<Column> selectColumns = criteria.getSelectColumns();
List<Column> columnsWithoutOffset = selectColumns.subList(
offset,
selectColumns.size());
Set<String> columnsMapped = new HashSet<String>();
for (Column column : columnsWithoutOffset)
{
final int nextOffset = totalOffset; if (!columnsMapped.contains(JOB_ID_EXPRESSION ) && JOB_ID_EXPRESSION.equals(
column.getSqlExpression()))
{
if (useMappingStrategy)
{
strategy.addColumn(nextOffset,
(res, inst) -> inst.setJobId( getJobId(res, nextOffset)));
} else
{
jobEntryTorque.setJobId( getJobId(resultSet, totalOffset));
}
columnsMapped.add( JOB_ID_EXPRESSION );
}
else if (!columnsMapped.contains(SECOND_EXPRESSION ) && SECOND_EXPRESSION.equals(
column.getSqlExpression()))
{
if (useMappingStrategy)
{
strategy.addColumn(nextOffset,
(res, inst) -> inst.setSecond( getSecond(res, nextOffset)));
} else
{
jobEntryTorque.setSecond( getSecond(resultSet, totalOffset));
}
columnsMapped.add( SECOND_EXPRESSION );
}
else if (!columnsMapped.contains(MINUTE_EXPRESSION ) && MINUTE_EXPRESSION.equals(
column.getSqlExpression()))
{
if (useMappingStrategy)
{
strategy.addColumn(nextOffset,
(res, inst) -> inst.setMinute( getMinute(res, nextOffset)));
} else
{
jobEntryTorque.setMinute( getMinute(resultSet, totalOffset));
}
columnsMapped.add( MINUTE_EXPRESSION );
}
else if (!columnsMapped.contains(HOUR_EXPRESSION ) && HOUR_EXPRESSION.equals(
column.getSqlExpression()))
{
if (useMappingStrategy)
{
strategy.addColumn(nextOffset,
(res, inst) -> inst.setHour( getHour(res, nextOffset)));
} else
{
jobEntryTorque.setHour( getHour(resultSet, totalOffset));
}
columnsMapped.add( HOUR_EXPRESSION );
}
else if (!columnsMapped.contains(WEEK_DAY_EXPRESSION ) && WEEK_DAY_EXPRESSION.equals(
column.getSqlExpression()))
{
if (useMappingStrategy)
{
strategy.addColumn(nextOffset,
(res, inst) -> inst.setWeekDay( getWeekDay(res, nextOffset)));
} else
{
jobEntryTorque.setWeekDay( getWeekDay(resultSet, totalOffset));
}
columnsMapped.add( WEEK_DAY_EXPRESSION );
}
else if (!columnsMapped.contains(DAY_OF_MONTH_EXPRESSION ) && DAY_OF_MONTH_EXPRESSION.equals(
column.getSqlExpression()))
{
if (useMappingStrategy)
{
strategy.addColumn(nextOffset,
(res, inst) -> inst.setDayOfMonth( getDayOfMonth(res, nextOffset)));
} else
{
jobEntryTorque.setDayOfMonth( getDayOfMonth(resultSet, totalOffset));
}
columnsMapped.add( DAY_OF_MONTH_EXPRESSION );
}
else if (!columnsMapped.contains(TASK_EXPRESSION ) && TASK_EXPRESSION.equals(
column.getSqlExpression()))
{
if (useMappingStrategy)
{
strategy.addColumn(nextOffset,
(res, inst) -> inst.setTask( getTask(res, nextOffset)));
} else
{
jobEntryTorque.setTask( getTask(resultSet, totalOffset));
}
columnsMapped.add( TASK_EXPRESSION );
}
else if (!columnsMapped.contains(EMAIL_EXPRESSION ) && EMAIL_EXPRESSION.equals(
column.getSqlExpression()))
{
if (useMappingStrategy)
{
strategy.addColumn(nextOffset,
(res, inst) -> inst.setEmail( getEmail(res, nextOffset)));
} else
{
jobEntryTorque.setEmail( getEmail(resultSet, totalOffset));
}
columnsMapped.add( EMAIL_EXPRESSION );
}
else if (!columnsMapped.contains(PROPERTY_EXPRESSION ) && PROPERTY_EXPRESSION.equals(
column.getSqlExpression()))
{
if (useMappingStrategy)
{
strategy.addColumn(nextOffset,
(res, inst) -> inst.setProperty( getProperty(res, nextOffset)));
} else
{
jobEntryTorque.setProperty( getProperty(resultSet, totalOffset));
}
columnsMapped.add( PROPERTY_EXPRESSION );
}
totalOffset++;
}
if (columnsMapped.isEmpty())
{
log.debug("no columns to map found in criteria, "
+ "returning null");
return null;
}
if (useMappingStrategy)
{
this.strategy.finish(9, true);
this.strategy.execute(resultSet, jobEntryTorque);
}
}
jobEntryTorque.setNew(false);
jobEntryTorque.setModified(false);
}
finally
{
jobEntryTorque.setLoading(false);
}
return jobEntryTorque;
}
/**
* Reads the value of the <code>columnIndex</code>'th column
* in the <code>resultSet</code> so that it can be used to set
* the field jobId in JobEntryTorque.
*
* @param resultSet the ResultSet to read from, not null.
* @param columnIndex the index in the resultSet which should be read.
*
* @return the content of the column.
*
* @throws SQLException if a problem occurs when reading
* from the resultSet.
*/
protected int getJobId(
ResultSet resultSet,
int columnIndex)
throws TorqueException
{
try
{
return resultSet.getInt(columnIndex);
}
catch (SQLException e)
{
throw new TorqueException(e);
}
}
/**
* Reads the value of the <code>columnIndex</code>'th column
* in the <code>resultSet</code> so that it can be used to set
* the field second in JobEntryTorque.
*
* @param resultSet the ResultSet to read from, not null.
* @param columnIndex the index in the resultSet which should be read.
*
* @return the content of the column.
*
* @throws SQLException if a problem occurs when reading
* from the resultSet.
*/
protected int getSecond(
ResultSet resultSet,
int columnIndex)
throws TorqueException
{
try
{
return resultSet.getInt(columnIndex);
}
catch (SQLException e)
{
throw new TorqueException(e);
}
}
/**
* Reads the value of the <code>columnIndex</code>'th column
* in the <code>resultSet</code> so that it can be used to set
* the field minute in JobEntryTorque.
*
* @param resultSet the ResultSet to read from, not null.
* @param columnIndex the index in the resultSet which should be read.
*
* @return the content of the column.
*
* @throws SQLException if a problem occurs when reading
* from the resultSet.
*/
protected int getMinute(
ResultSet resultSet,
int columnIndex)
throws TorqueException
{
try
{
return resultSet.getInt(columnIndex);
}
catch (SQLException e)
{
throw new TorqueException(e);
}
}
/**
* Reads the value of the <code>columnIndex</code>'th column
* in the <code>resultSet</code> so that it can be used to set
* the field hour in JobEntryTorque.
*
* @param resultSet the ResultSet to read from, not null.
* @param columnIndex the index in the resultSet which should be read.
*
* @return the content of the column.
*
* @throws SQLException if a problem occurs when reading
* from the resultSet.
*/
protected int getHour(
ResultSet resultSet,
int columnIndex)
throws TorqueException
{
try
{
return resultSet.getInt(columnIndex);
}
catch (SQLException e)
{
throw new TorqueException(e);
}
}
/**
* Reads the value of the <code>columnIndex</code>'th column
* in the <code>resultSet</code> so that it can be used to set
* the field weekDay in JobEntryTorque.
*
* @param resultSet the ResultSet to read from, not null.
* @param columnIndex the index in the resultSet which should be read.
*
* @return the content of the column.
*
* @throws SQLException if a problem occurs when reading
* from the resultSet.
*/
protected int getWeekDay(
ResultSet resultSet,
int columnIndex)
throws TorqueException
{
try
{
return resultSet.getInt(columnIndex);
}
catch (SQLException e)
{
throw new TorqueException(e);
}
}
/**
* Reads the value of the <code>columnIndex</code>'th column
* in the <code>resultSet</code> so that it can be used to set
* the field dayOfMonth in JobEntryTorque.
*
* @param resultSet the ResultSet to read from, not null.
* @param columnIndex the index in the resultSet which should be read.
*
* @return the content of the column.
*
* @throws SQLException if a problem occurs when reading
* from the resultSet.
*/
protected int getDayOfMonth(
ResultSet resultSet,
int columnIndex)
throws TorqueException
{
try
{
return resultSet.getInt(columnIndex);
}
catch (SQLException e)
{
throw new TorqueException(e);
}
}
/**
* Reads the value of the <code>columnIndex</code>'th column
* in the <code>resultSet</code> so that it can be used to set
* the field task in JobEntryTorque.
*
* @param resultSet the ResultSet to read from, not null.
* @param columnIndex the index in the resultSet which should be read.
*
* @return the content of the column.
*
* @throws SQLException if a problem occurs when reading
* from the resultSet.
*/
protected String getTask(
ResultSet resultSet,
int columnIndex)
throws TorqueException
{
try
{
return resultSet.getString(columnIndex);
}
catch (SQLException e)
{
throw new TorqueException(e);
}
}
/**
* Reads the value of the <code>columnIndex</code>'th column
* in the <code>resultSet</code> so that it can be used to set
* the field email in JobEntryTorque.
*
* @param resultSet the ResultSet to read from, not null.
* @param columnIndex the index in the resultSet which should be read.
*
* @return the content of the column.
*
* @throws SQLException if a problem occurs when reading
* from the resultSet.
*/
protected String getEmail(
ResultSet resultSet,
int columnIndex)
throws TorqueException
{
try
{
return resultSet.getString(columnIndex);
}
catch (SQLException e)
{
throw new TorqueException(e);
}
}
/**
* Reads the value of the <code>columnIndex</code>'th column
* in the <code>resultSet</code> so that it can be used to set
* the field property in JobEntryTorque.
*
* @param resultSet the ResultSet to read from, not null.
* @param columnIndex the index in the resultSet which should be read.
*
* @return the content of the column.
*
* @throws SQLException if a problem occurs when reading
* from the resultSet.
*/
protected byte[] getProperty(
ResultSet resultSet,
int columnIndex)
throws TorqueException
{
try
{
byte[] value = resultSet.getBytes(columnIndex);
if (resultSet.wasNull())
{
value = null;
}
return value;
}
catch (SQLException e)
{
throw new TorqueException(e);
}
}
}