⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deptinfoutil.java.svn-base

📁 一个timesheet程序,用来统计开发人员的度量衡web在线程序.用于软件行业
💻 SVN-BASE
字号:
package com.nsi.components.util;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.nsi.components.department.DeptDtl;
import com.nsi.components.department.DeptRole;
import com.nsi.control.exceptions.NsiEventException;
import com.nsi.persistence.DataSrcUtil;
import com.nsi.persistence.IsqlDataSource;
import com.nsi.util.ValHelper;

/**
 * @author Chris Ye, created on Oct 10, 2008
 *
 * DeptInfoUtil
 */
public final class DeptInfoUtil
{
	private static Log log = LogFactory.getLog(DeptInfoUtil.class);
	/**
	 * private constructor of DeptInfoUtil, prevent instantiation
	 */
	private DeptInfoUtil()
	{
	}
	private static class DeptInfoUtilHolder
	{
		static final DeptInfoUtil deptInfoUtil = new DeptInfoUtil();
	}
	/**
	 * @return an instance of DeptInfoUtil
	 */
	public static DeptInfoUtil getInstance()
	{
		return DeptInfoUtilHolder.deptInfoUtil;
	}
	public List<DeptDtl> getDeptlist()
	{
		List<DeptDtl> list = new ArrayList<DeptDtl>();
		List<Map<String,String>> result = new ArrayList<Map<String,String>>();
		String sSql = "select departmentid, department from ct_department order by department desc";
		try
		{
			IsqlDataSource src = DataSrcUtil.getInstance().getDataSource();
			Connection conn = null;
			try
			{
				conn = src.getConnection();
				result = src.executeRetrieve(conn, sSql);
				src.closeConn(conn);
			}
			catch( SQLException se )
			{
				log.error( "getDeptlist() caught SQLException: ", se );
			}
			catch( Exception ex )
			{
				log.error( "getDeptlist() caught Exception: ", ex );
			}
			finally
			{
				src.closeConn(conn);
			}
			if( !result.isEmpty())
			{
				int size = result.size();
				for( int i=0;i<size;i++)
				{
					Map<String,String> resultMap = result.get(i);
					DeptDtl dtl = new DeptDtl( ValHelper.getInstance().getValue(resultMap, "departmentid"), ValHelper.getInstance().getValue(resultMap, "department"));
					list.add( dtl);
				}
			}
		}
		catch( NsiEventException nsiex )
		{
			log.error( "getDeptlist() caught NsiEventException: ", nsiex );
		}
		return list;
	}
	public List<DeptRole> getDeptrolelist()
	{
		List<DeptRole> list = new ArrayList<DeptRole>();
		List<Map<String,String>> result = new ArrayList<Map<String,String>>();
		String sSql = "select deptroleid, deptrole from ct_dept_role order by deptroleid";
		try
		{
			IsqlDataSource src = DataSrcUtil.getInstance().getDataSource();
			Connection conn = null;
			try
			{
				conn = src.getConnection();
				result = src.executeRetrieve(conn, sSql);
				src.closeConn(conn);
			}
			catch( SQLException se )
			{
				log.error( "getDeptrolelist() caught SQLException: ", se );
			}
			catch( Exception ex )
			{
				log.error( "getDeptrolelist() caught Exception: ", ex );
			}
			finally
			{
				src.closeConn(conn);
			}
			if( !result.isEmpty())
			{
				int size = result.size();
				for( int i=0;i<size;i++)
				{
					Map<String,String> resultMap = result.get(i);
					DeptRole deptrole = new DeptRole( ValHelper.getInstance().getValue(resultMap, "deptroleid"), ValHelper.getInstance().getValue(resultMap, "deptrole"));
					list.add( deptrole);
				}
			}
		}
		catch( NsiEventException nsiex )
		{
			log.error( "getDeptrolelist() caught NsiEventException: ", nsiex );
		}
		return list;
	}

	public void setDeptmap( Map<String,String>deptmap) throws NsiEventException
	{
		String sSql = "select departmentid, department from ct_department order by department desc";
		IsqlDataSource src = DataSrcUtil.getInstance().getDataSource();
		Connection conn = null;
		try
		{
			conn = src.getConnection();
			List<Map<String,String>> result = src.executeRetrieve(conn, sSql);
			src.closeConn(conn);
			int size = result.size();
			for( int i=0;i<size;i++)
			{
				Map<String,String> resultMap = result.get(i);
				deptmap.putAll(resultMap);
			}
		}
		catch( SQLException se )
		{
			log.error( "getEmployeeTypeList() caught SQLException: ", se );
		}
		catch( Exception ex )
		{
			log.error( "getEmployeeTypeList() caught Exception: ", ex );
		}
		finally
		{
			src.closeConn(conn);
		}
	}
	public void setDeptrolemap( Map<String,String>deptrolemap) throws NsiEventException
	{
		String sSql = "select deptroleid, deptrole from ct_dept_role order by deptroleid";
		IsqlDataSource src = DataSrcUtil.getInstance().getDataSource();
		Connection conn = null;
		try
		{
			conn = src.getConnection();
			List<Map<String,String>> result = src.executeRetrieve(conn, sSql);
			src.closeConn(conn);
			int size = result.size();
			for( int i=0;i<size;i++)
			{
				Map<String,String> resultMap = result.get(i);
				deptrolemap.putAll(resultMap);
			}
		}
		catch( SQLException se )
		{
			log.error( "getEmployeeTypeList() caught SQLException: ", se );
		}
		catch( Exception ex )
		{
			log.error( "getEmployeeTypeList() caught Exception: ", ex );
		}
		finally
		{
			src.closeConn(conn);
		}
	}
}

⌨️ 快捷键说明

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