taskquery.java

来自「Java的框架」· Java 代码 · 共 143 行

JAVA
143
字号
package mcaps.apps.prrm.task.dao.jdbc.query;

import java.sql.ResultSet;
import java.sql.SQLException;

import javax.sql.DataSource;


import mcaps.apps.prrm.task.dao.util.TaskField;
import mcaps.apps.prrm.task.model.Category;
import mcaps.apps.prrm.task.model.Priority;
import mcaps.apps.prrm.task.model.Status;
import mcaps.apps.prrm.task.model.Task;
import mcap.core.base.dao.jdbc.SQLQuery;
import mcap.core.base.dao.util.SortOrder;
import mcaps.apps.prrm.util.TableNameConstants;

/**
 * The class that extends the SQLQuery class to customize
 * the query for task.
 * 
 * @author jov
 * @date Oct 12, 2005
 * @version 1.0.1.0
 */
public class TaskQuery extends SQLQuery {

	
	/**
	 * The default constructor that accepts datasource and 
	 * provides the contact table name to initialize the super
	 * class constructor.
	 * @param ds
	 */
	public TaskQuery(DataSource ds) {
		super(ds,TableNameConstants.TASK_TABLENAME);
	}

	/**
	 * The constructor that accepts datasource and additional 
	 * parameters like sort field index and sort order 
	 * and provides table name to initialize the super
	 * class constructor.
	 * @param ds the datasource object
	 * @param sortColumnIdx the index of the field in which used as sort column
	 * @param order the sort order
	 */
	public TaskQuery(DataSource ds, int sortColumnIdx, SortOrder order) {
		super(ds, TableNameConstants.TASK_TABLENAME, sortColumnIdx, order);
	}

	/**
	 * The constructor that accepts datasource and additional 
	 * parameters like sort field index array and sort order array
	 * and provides table name to initialize the super
	 * class constructor.
	 * @param ds the datasource object
	 * @param sortFieldIdxArray the array off sort field index
	 * @param orderArray the array of the sort order for the sort fields
	 */
	public TaskQuery(DataSource ds, int[] sortColumnIdxArray, SortOrder[] sortOrderArray) {
		super(ds, TableNameConstants.TASK_TABLENAME, sortColumnIdxArray, sortOrderArray);
	}

	/**
	 * The constructor that accepts datasource and additional 
	 * parameters like where clause and param types of the where
	 * clause parameters and provides table name to initialize the super
	 * class constructor.
	 * @param ds the datasource object
	 * @param whereClause where clause to refine the query
	 * @param paramTypes the array of parameter types
	 */
	public TaskQuery(DataSource ds, String whereClause, int[] paramTypes){
		super(ds, TableNameConstants.TASK_TABLENAME, whereClause, paramTypes);
	}
	
	/**
	 * The constructor that accepts datasource and additional 
	 * parameters like where clause, param types of the where
	 * clause parameters, sort column index, sort order and provides 
	 * table name to initialize the super class constructor.
	 * @param ds the datasource object
	 * @param whereClause where clause to refine the query
	 * @param paramTypes the array of parameter types
	 * @param sortFieldIdx the sort field index
	 * @param order the sort order
	 */
	public TaskQuery(DataSource ds, String whereClause, 
													int[] paramTypes, int sortColIdx,
													SortOrder order) {
		super(ds, TableNameConstants.TASK_TABLENAME, whereClause, paramTypes, sortColIdx, order);
	}

	/**
	 * The constructor that accepts datasource and additional 
	 * parameters like where clause and param types of the where
	 * clause parameters, sort field index array, sort order
	 * array and provides table name to initialize the super
	 * class constructor.
	 * @param ds the datasource object
	 * @param whereClause where clause to refine the query
	 * @param paramTypes the array of parameter types
	 * @param sortFieldIdxArray the array of sort field index
	 * @param orderArray the array of sort order
	 */
	public TaskQuery(DataSource ds, String whereClause, 
													int[] paramTypes, int[] sortColumnIdxArray, 
													SortOrder[] sortOrderArray) {
		super(ds, TableNameConstants.TASK_TABLENAME, whereClause, paramTypes, sortColumnIdxArray, sortOrderArray);
	}

	/* (non-Javadoc)
	 * @see org.springframework.jdbc.object.MappingSqlQuery#mapRow(java.sql.ResultSet, int)
	 */
	protected Object mapRow(ResultSet rs, int rowNum) throws SQLException {
		int i = 0;
		Task task = new Task();
		task.setId(new Integer(rs.getInt(TaskField.FIELDS[i++])));
		task.setCategory(rs.getString(TaskField.FIELDS[i++]));
		task.setPriority(rs.getString(TaskField.FIELDS[i++]));
		task.setStatus(rs.getString(TaskField.FIELDS[i++]));
		task.setRemarks(rs.getString(TaskField.FIELDS[i++]));
		task.setAssignedUserId(rs.getString(TaskField.FIELDS[i++]));
		task.setRoadDefectId(new Integer(rs.getInt(TaskField.FIELDS[i++])));
		task.setDueDate(rs.getTimestamp(TaskField.FIELDS[i++]));
		task.setCreationTime(rs.getTimestamp(TaskField.FIELDS[i++]));
		task.setLastModifiedTime(rs.getTimestamp(TaskField.FIELDS[i++]));
		return task;
	}
	
	/* (non-Javadoc)
	 * @see mcapss.prrm.base.dao.jdbc.SQLQuery#getSelectFieldsName()
	 */
	protected String[] getSelectFieldsName(){
		return TaskField.FIELDS;		
	}

	


}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?