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

📄 actinfoutil.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.HashMap;
import java.util.List;
import java.util.Map;

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

import com.nsi.components.proactivity.ActCatInfo;
import com.nsi.components.proactivity.ActInfo;
import com.nsi.control.exceptions.NsiEventException;
import com.nsi.persistence.DataSrcUtil;
import com.nsi.persistence.IsqlDataSource;
import com.nsi.util.ValHelper;

public final class ActInfoUtil
{
	private static Log log = LogFactory.getLog(ActInfoUtil.class);
	/**
	 * private constructor of ActInfoUtil, prevent instantiation
	 */
	private ActInfoUtil()
	{
	}
	private static class ActInfoUtilHolder
	{
		static final ActInfoUtil actInfoUtil = new ActInfoUtil();
	}
	/**
	 * @return an instance of ActInfoUtil
	 */
	public static ActInfoUtil getInstance()
	{
		return ActInfoUtilHolder.actInfoUtil;
	}
	public Map<String,String> getActmap()
	{
		Map<String,String> map = new HashMap<String,String>();
		List<Map<String,String>> result = getActresult();
		if(!result.isEmpty())
		{
			int size = result.size();
			for (int i = 0; i < size; i++)
			{
				Map<String,String> resultmap = result.get(i);
				map.put(ValHelper.getInstance().getValue(resultmap, "activityid"), ValHelper.getInstance().getValue(resultmap, "activity"));
			}
		}
		return map;
	}
	public Map<String,String> getActmapByactid(String actid)
	{
		Map<String,String> map = new HashMap<String,String>();
		List<Map<String,String>> result = getActresultByactid(actid);
		if(!result.isEmpty())
		{
			int size = result.size();
			for (int i = 0; i < size; i++)
			{
				Map<String,String> resultmap = result.get(i);
				map.put(ValHelper.getInstance().getValue(resultmap, "activityid"), ValHelper.getInstance().getValue(resultmap, "activity"));
			}
		}
		return map;
	}
	public List<ActCatInfo> getActcatlist()
	{
		List<ActCatInfo> list = new ArrayList<ActCatInfo>();
		List<Map<String,String>> result = getActcatresult();
		if(!result.isEmpty())
		{
			int size = result.size();
			for (int i = 0; i < size; i++)
			{
				Map<String,String> resultmap = result.get(i);
				ActCatInfo info = new ActCatInfo();
				info.setActcatid(ValHelper.getInstance().getValue(resultmap, "actcatid"));
				info.setCatgroup(ValHelper.getInstance().getValue(resultmap, "catgroup"));
				info.setCategory(ValHelper.getInstance().getValue(resultmap, "category"));
				list.add(info);
			}
		}
		return list;
	}

	public List<Map<String,String>> getActcatresult()
	{
		List<Map<String,String>> result = new ArrayList<Map<String,String>>();
		String sSql = 	"select actcatid, catgroup, category from ct_act_category order by catgroup, category"; 
		try
		{
			IsqlDataSource src = DataSrcUtil.getInstance().getDataSource();
			Connection conn = null;
			try
			{
				conn = src.getConnection();
				result = src.executeRetrieve(conn, sSql);
			}
			catch( SQLException se )
			{
				log.error( "getActresult() caught SQLException: " + se );
			}
			catch( Exception ex )
			{
				log.error( "getActresult() caught Exception: " + ex );
			}
			finally
			{
				src.closeConn(conn);
			}
		}
		catch( NsiEventException nsiex )
		{
		}
		return result;
	}
	public List<Map<String,String>> getActresult()
	{
		List<Map<String,String>> result = new ArrayList<Map<String,String>>();
		String sSql = 	"select activityid, activity from ct_activity order by activity"; 
		try
		{
			IsqlDataSource src = DataSrcUtil.getInstance().getDataSource();
			Connection conn = null;
			try
			{
				conn = src.getConnection();
				result = src.executeRetrieve(conn, sSql);
			}
			catch( SQLException se )
			{
				log.error( "getActresult() caught SQLException: " + se );
			}
			catch( Exception ex )
			{
				log.error( "getActresult() caught Exception: " + ex );
			}
			finally
			{
				src.closeConn(conn);
			}
		}
		catch( NsiEventException nsiex )
		{
		}
		return result;
	}
	public List<ActInfo> getCollection()
	{
		List<ActInfo> list = new ArrayList<ActInfo>();
		List<Map<String,String>> result = getActresult();
		if(!result.isEmpty())
		{
			int size = result.size();
			for (int i = 0; i < size; i++)
			{
				Map<String,String> resultmap = result.get(i);
				ActInfo info = new ActInfo( ValHelper.getInstance().getValue(resultmap, "activityid"), ValHelper.getInstance().getValue(resultmap, "activity"));
				list.add(info);
			}
		}
		return list;
	}
	public List<ActInfo> getCollection( String actid )
	{
		List<ActInfo> list = new ArrayList<ActInfo>();
		List<Map<String,String>> result = getActresultByactid(actid);
		if(!result.isEmpty())
		{
			int size = result.size();
			for (int i = 0; i < size; i++)
			{
				Map<String,String> resultmap = result.get(i);
				ActInfo info = new ActInfo( ValHelper.getInstance().getValue(resultmap, "activityid"), ValHelper.getInstance().getValue(resultmap, "activity"));
				list.add(info);
			}
		}
		return list;
	}
	public List<Map<String,String>> getActresultByactid(String actid)
	{
		List<Map<String,String>> result = new ArrayList<Map<String,String>>();
		String sSql = 	"select activityid, activity from ct_activity " + 
							"where actcatid in ( " + actid + ") " + 
							"and activityid not in (340, 341, 342, 343, 344) " + 
							"order by activity";
		try
		{
			IsqlDataSource src = DataSrcUtil.getInstance().getDataSource();
			Connection conn = null;
			try
			{
				conn = src.getConnection();
				result = src.executeRetrieve(conn, sSql);
			}
			catch( SQLException se )
			{
				log.error( "getActresultByactcatid() caught SQLException: " + se );
			}
			catch( Exception ex )
			{
				log.error( "getActresultByactcatid() caught Exception: " + ex );
			}
			finally
			{
				src.closeConn(conn);
			}
		}
		catch( NsiEventException nsiex )
		{
		}
		return result;
	}
}

⌨️ 快捷键说明

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