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

📄 hisrepository.java

📁 电信的网厅的整站代码
💻 JAVA
字号:
package com.doone.fj1w.fjmgr.repos.service;

import com.doone.data.DataRow;
import com.doone.data.DacClient;
import com.doone.data.DataTable;
import com.doone.util.FileLogger;

import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: lizhx
 * Date: 2005-7-27
 * Time: 22:09:18
 * Email:lizx@doone.com.cn
 */
public class HisRepository implements IHisRepositoryInfo {
    DataRow hisreposInfo;
    private DacClient _dbClient;
    // [start] 表结构初始化
    private static DataTable repos_Struct;
    static {
		// 负责加载表结构信息,以便其它地方多次使用该表结构。而不需要手工重新构建。

		loadTableStruct();
	}
    static void loadTableStruct() {
		try {
			// 通过查询数据表得到一个空数据的表结构。
            StringBuffer sql = new StringBuffer();
            sql.append("select ");
            sql.append("REPOSITORYHISID, ");
			sql.append("REPOSITORYID, ");
			sql.append("CONTENT, ");
			sql.append("CHANGETIME, ");
			sql.append("STAFFID ");
			sql.append(" from Th_Repository");
			sql.append(" where 1=2");

			DacClient dbClient = new DacClient();
			repos_Struct = dbClient.executeQuery(sql.toString());
		} catch (Exception ex) {
			FileLogger.getLogger().warn("加载表结构信息时出现异常:", ex);
		}
	}
    // [end]

// [start] 历史知识库对象控制集。
    public HisRepository() {
        hisreposInfo = null;
        _dbClient = null;
    }

    /**
	 * 构建历史知识库信息的结构,并创建一新的空行。
	 *
	 * @return 具有与数据库相同结构的新行。
	 */
	private DataRow buildStruct() {
		if (repos_Struct == null)
			loadTableStruct();

		if (repos_Struct == null)
			throw new RuntimeException("初始化数据结构时出错,程序不能完成初始化。");

		DataTable dt = repos_Struct.copyStruct();

		DataRow dr = dt.newRow();
		dt.getRows().add(dr);

		return dr;
	}

    /**
	 * 新建历史知识库实例,以便用于历史知识库的添加。
	 *
	 * @param dbClient
	 *            用于将信息更改存储到数据库中的数据库连接。
	 * @return 新建历史的知识库实现对象。
	 */
	public static HisRepository newInstance(DacClient dbClient) {
		HisRepository ret = new HisRepository();
		ret._dbClient = dbClient;
		ret.hisreposInfo = ret.buildStruct();
		try {
			ret.setRepositoryHisId((new Long(dbClient.getSequence("SEQ_REPOSITORYHISID"))));
			ret.setChangeTime(new Date());

		} catch (Exception ex) {
			FileLogger.getLogger().warn("新建历史知识库实例时发生异常:", ex);

			throw new RuntimeException(ex);
		}
		return ret;
	}

    /**
	 * 根据历史知识库标识获取历史知识库实例信息。
	 *
	 * @param dbClient
	 *            用于存储或获取数据库中信息的数据库连接。
	 * @param lHisRepositoryId
	 *            需要获取的历史知识库标识。
	 * @return 指定历史知识库的信息对象。
	 */
	public static HisRepository getInstance(DacClient dbClient, long lHisRepositoryId) {
		HisRepository ret = new HisRepository();
		ret._dbClient = dbClient;
		try {
			// 通过查询数据表得到一个空数据的表结构。

            StringBuffer sql = new StringBuffer();
            sql.append("select ");
            sql.append("REPOSITORYHISID, ");
			sql.append("REPOSITORYID, ");
			sql.append("CONTENT, ");
			sql.append("CHANGETIME, ");
			sql.append("STAFFID ");
			sql.append(" from Th_Repository");
			sql.append(" where REPOSITORYHISID=?");
            Object[] aParam = new Object[1];
			aParam[0] =new Long(lHisRepositoryId);
			DataTable dt = dbClient.executeQuery(sql.toString(),aParam);
			if (dt.getRows().getCount() == 1) {
				ret.hisreposInfo = dt.getRow(0);
			} else if (lHisRepositoryId == 0) {
				// 如果要获取的历史知识库信息是空数据库,特殊处理。
				ret.hisreposInfo = dt.newRow();
				dt.getRows().add(ret.hisreposInfo);
				ret.hisreposInfo.setValue("REPOSITORYHISID", new Long(0));
				ret.hisreposInfo.setValue("content","");
                //需要添加信息

			} else if (dt.getRows().getCount() > 1)
				throw new RuntimeException("获取历史知识库数据,指定的历史知识库标识在库中不存在。");
		} catch (Exception ex) {
			FileLogger.getLogger().warn("加载历史知识库信息时出现异常:", ex);

			throw new RuntimeException(ex);
		}

		return ret;
	}

    public void save() {
		try {
			// XXX 进行必要的数据有效性检查。
			if (_dbClient == null)
				_dbClient = new DacClient();

			_dbClient.updateDataRow(hisreposInfo);
		} catch (Exception ex) {
			FileLogger.getLogger().warn("保存历史知识库信息时出现异常:", ex);

			throw new RuntimeException(ex);
		}
	}


    /** 获取所有下一级子对象。 */
	public HisRepository[] getHisRepositoryById(Long lRepositoryId) {
		HisRepository[] ret = null;
		try {
			DataTable dt = getChildList(lRepositoryId);

			if (dt.getRows().getCount() > 0) {
				ret = new HisRepository[dt.getRows().getCount()];
				for (int i = 0; i < ret.length; i++) {
					ret[i] = new HisRepository();
					ret[i]._dbClient = _dbClient;
					ret[i].hisreposInfo = dt.getRow(i);
				}
			}
		}
		catch (Exception ex) {
			FileLogger.getLogger().warn("加载对象历史知识库信息时出现异常:", ex);

			throw new RuntimeException(ex);
		}

		return ret;
	}

    /** 获取所有下一级子对象列表。 */
	DataTable getChildList(Long lRepositoryId) {
		DataTable ret = null;
		try {
			StringBuffer sql = new StringBuffer();
            sql.append("select ");
            sql.append("REPOSITORYHISID, ");
			sql.append("REPOSITORYID, ");
			sql.append("CONTENT, ");
			sql.append("CHANGETIME, ");
			sql.append("STAFFID ");
			sql.append(" from Th_Repository");
			sql.append(" where REPOSITORYID=?");
            sql.append(" order by CHANGETIME ");
            Object[] aParam = new Object[1];
			aParam[0] = lRepositoryId;
			ret = _dbClient.executeQuery(sql.toString(), aParam);
		}
		catch (Exception ex) {
			FileLogger.getLogger().warn("加载对象历史知识库信息时出现异常:", ex);

			throw new RuntimeException(ex);
		}

		return ret;
	}

    /**
	 * @return 知识库变更历史ID  , seq : SEQ_REPOSITORYHISID
	 */

    public Long getRepositoryHisId() {
        return new Long(hisreposInfo.getLong("RepositoryHisId"));

    }
    /**
	 * @return 知识库ID
	 */
    public Long getRepositoryId() {
        return new Long(hisreposInfo.getLong("RepositoryId"));
    }
    /**
	 * @return 变更内容
	 */

    public String getContent() {
        return hisreposInfo.getString("Content");
    }
   /**
	 * @return 变更时间
	 */
    public Date getChangeTime() {
        return hisreposInfo.getDate("ChangeTime");
    }
    /**
	 * @return //员工标识
	 */

    public Long getStaffId() {
        return new Long(hisreposInfo.getLong("StaffId"));
    }

    //历史知识库变更历史ID  , seq : SEQ_REPOSITORYHISID
    public void setRepositoryHisId(Long newRepositoryHisId) {
        hisreposInfo.setValue("RepositoryHisId", newRepositoryHisId);
    }

    //知识库ID
    public void setRepositoryId(Long newRepositoryId) {
        hisreposInfo.setValue("RepositoryId", newRepositoryId);
    }

    //变更内容
    public void setContent(String newContent) {
        hisreposInfo.setValue("Content", newContent);
    }

    //变更时间
    public void setChangeTime(Date newChangeTime) {
       hisreposInfo.setValue("ChangeTime", newChangeTime);
    }

    //员工标识
    public void setStaffId(Long newStaffId) {
       hisreposInfo.setValue("StaffId", newStaffId);
    }
}

⌨️ 快捷键说明

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